The readonly expression can be replaced and edited as a whole
Description
The readonly expression can be replaced and edited as a whole
Steps to Reproduce
- go to https://cortexjs.io/mathlive/guides/fill-in-the-blank/ and see the first readonly expression
- select all by double-clicking
- replace all contents directly by typing on the keyboard
https://github.com/user-attachments/assets/9bb0dcd6-c8fc-46a9-a228-a3478120e33e
Actual Behavior
The readonly expression is replaced
Expected Behavior
Invalid operation
Environment
MathLive version not provided
macOS Chrome Version 127.0.6533.89 (Official Build) (arm64)
Cleaned up comment above to make it more readable.
I tried doing a bit of digging on this without much luck. For future reference, what I found is that the physical keyboard fails to overwrite the readonly field (as expected) while the virtual keyboard shows the same behaviour reported in this issue.
Strangely, pressing Delete on the virtual keyboard does not delete the selection, while typing another key (e.g. a number) does what reported in this issue.
The only slightly suspicious thing I found is that inside the function perform in commands.ts, when command == "deleteBackward" COMMANDS[selector].changeContent is set to true (as I would expect) while when command == "insert" (as it is for when the user types a digit), then COMMANDS[selector].changeContent is set to false.
I was not able to understand where, how and why changeContent is set in a way or the other
Additional comment: in the debugger I changed COMMANDS["insert"].changeContent from false to true and I'm no longer able to reproduce the bug reported in the issue.
I was not able though to find where this value is set in the code and I'm still not sure about whether this is the intended meaning of this flag. @arnog do you think this is a valid solution?