Skip to content

Update the mqeditor to use MathQuill's new internal toolbar.#1417

Merged
Alex-Jordan merged 3 commits into
openwebwork:PG-2.21from
drgrice1:mathquill-internal-toolbar
May 27, 2026
Merged

Update the mqeditor to use MathQuill's new internal toolbar.#1417
Alex-Jordan merged 3 commits into
openwebwork:PG-2.21from
drgrice1:mathquill-internal-toolbar

Conversation

@drgrice1
Copy link
Copy Markdown
Member

@drgrice1 drgrice1 commented May 23, 2026

These are changes needed to use the new internal toolbar implemented in openwebwork/mathquill#46. To test this you need to use that branch. Clone that branch somewhere on the webwork2 server, and then in the directory of that clone execute

npm ci
npm run build
npm link

Then checkout the branch for this pull request in the /opt/webwork/pg directory (or wherever you have the PG repository). Make sure you run npm ci in the pg/htdocs directory before doing the following so that the JavaScript and css for PG is all updated.

Then in the pg/htdocs directory run npm link @openwebwork/mathquill. After doing so if you look at pg/htdocs/node_modules/@openwebwork/mathquill you will see that it is now a link to the MathQuill clone above.

Now restart the webwork2 app.

One last important step. Since the package.json file is not changed (so the version of @openwebwork/mathquill is still reported as the same), the browser may still load the cached version of MathQuill. So you may need to do a hard refresh in the browser to get it to load the updated MathQuill javascript.

When you are done testing this branch, execute npm ci again to remove the symbolic link and go back to using the currently published MathQuill version.

Once openwebwork/mathquill#46 is merged, I will publish the changes in openwebwork/mathquill#46 and add it to this pull request. So don't merge this pull request until then.

Edit: Now that openwebwork/mathquill#46 has been merged and published, you can just test this by running npm ci as usual.

@Alex-Jordan
Copy link
Copy Markdown
Contributor

I'm unsure that I am testing this correctly. I cloned the mathquill repo at /opt/webwork/mathquill and then I executed the commands above in that repo.

Then I checked out this branch of pg and in pg/htdocs I ran npm link @openwebwork/mathquill. I restarted webwork2. In a problem, I don't see changes with the toolbar. I understand they would largely be invisible to me. But for instance the "Disable Toolbar" whitespace issue from #1415 is still showing for me, so I think something I am doing is wrong.

@drgrice1 drgrice1 force-pushed the mathquill-internal-toolbar branch from 9cafe67 to 45bdd18 Compare May 24, 2026 10:41
@drgrice1
Copy link
Copy Markdown
Member Author

I changed the testing instructions a bit. There were some steps I missed that might be why you weren't seeing the changes in effect.

@Alex-Jordan
Copy link
Copy Markdown
Contributor

I am testing this again, and I followed the instructions.

Now when I click into an answer blank, I do not see the toolbar. Perhaps I had disabled it. But control-clicking does not give me the ususal Enable/Disable option. Instead I just get a generic input menu:

Screenshot 2026-05-26 at 1 43 55 PM

There are no console errors.

I'm using Firefox 151.0.1 on a Mac OS Tahoe 26.2.

@drgrice1
Copy link
Copy Markdown
Member Author

Do you have any console errors or warnings?

@drgrice1 drgrice1 force-pushed the mathquill-internal-toolbar branch 2 times, most recently from a526e6f to ec03fce Compare May 26, 2026 20:50
@Alex-Jordan
Copy link
Copy Markdown
Contributor

There are no console errors.

@drgrice1
Copy link
Copy Markdown
Member Author

I am not sure what is going wrong for you. Can you delete the local storage key named MQEditorToolbarEnabled to see if the toolbar works (assuming you have that key)?

@drgrice1
Copy link
Copy Markdown
Member Author

What is the minimized file generated for the mqeditor.js file? Is it js/MathQuill/mqeditor.fa95117d.min.js?

@drgrice1
Copy link
Copy Markdown
Member Author

Can you verify that if you execute ls -l /opt/webwork/pg/htdocs/node_modules/@openwebwork it shows that mathquill is a symbolic link?

Try executing ./generate-assets.js from the pt/htdocs directory and restart the webwork2 app. Executing the generate-assets.js script will make sure that you have the correct minified javascript and css files for the pull request, but won't change the symbolic link back to the actual upstream @openwebwork/mathquill package contents (npm ci will do that).

@Alex-Jordan
Copy link
Copy Markdown
Contributor

Can you delete the local storage key named MQEditorToolbarEnabled to see if the toolbar works (assuming you have that key)?

In local storage, I saw that variable, and it is set to true. So I didn't think this would help.

But I deleted it anyway, and reloaded the page. Now everything is working. And I also see the excess whitespace from "Disable Toolbar" is gone, so I know I'm on the right branch.

So....good? Is there anything I should do to test the other changes? Would Apple VoiceOver reveal changes now?

@drgrice1
Copy link
Copy Markdown
Member Author

I have not tested with Apple VoiceOver. Testing with that would be good. There should be differences between this pull request and the PG-2.21 branch. Particularly when you use toolbar buttons.

@Alex-Jordan
Copy link
Copy Markdown
Contributor

Alright, I gave it a go. But using Apple VoiceOver is torture. Either it's broken on my Mac, or navigation with that on just makes no sense. I tried using Apple's tutorial too, and it doesn't help. I think I would need to use it in person with a human training me.

So I have nothing to add. But nothing seems broken! So I will approve the PR.

@drgrice1
Copy link
Copy Markdown
Member Author

I remember testing it on my daughter's school MacBook at some point. I didn't know how to use it either. I also tested the Android TalkBack, and had much the same experience. I have figured out how to use Gnome Orca and NCDA, but that also took some time to figure out. Screen reader usage does seem to not be easy.

@somiaj
Copy link
Copy Markdown
Contributor

somiaj commented May 27, 2026

@drgrice1 npm link wants write access to to /usr/local/lib/node_modules. I thought there was a way to link this without going through that extra step so I can link to mathquill repo more directly? Or is there a way to specify where to put the node modules in $HOME?

@drgrice1
Copy link
Copy Markdown
Member Author

Yeah, I set npm to use a local location (~/.local/lib/node_modules). I didn't think about that. Add prefix=~/.local to the .npmrc file to get this.

drgrice1 added 2 commits May 27, 2026 15:32
These are changes needed to use the new internal toolbar implemented in
openwebwork/mathquill#46.  To test this you need
to use that branch. Clone that branch somewhere on the webwork2 server,
and then in the directory of that clone execute

```bash
npm ci
npm run build
npm link
```

Then in the `pg/htdocs` directory run `npm link @openwebwork/mathquill`.
After doing so if you look at `pg/htdocs/node_modules/@openwebwork/mathquill`
you will see that it is now a link to the MathQuill clone above.

Execute `npm ci` again to reset that back to the currently published
MathQuill version.

Once openwebwork/mathquill#46 is merged, I will
publish it and add it to this pull request.  So don't merge this pull
request until then.
@drgrice1 drgrice1 force-pushed the mathquill-internal-toolbar branch from ec03fce to dd880ca Compare May 27, 2026 20:33
@somiaj
Copy link
Copy Markdown
Contributor

somiaj commented May 27, 2026

In testing this, the enable/disable toolbar seems to be for individual mathquilll blanks when initially changing the setting.

I have a problem, multiple answer blanks, toolbar is enabled. I click disable toolbar, I go to the next blank, it is still enabled. In effect I can enable/disable per answer box of a currently open problem.

Now if I reload the page, the default is set to whatever the last setting was for enabled/disabled. So the initial load they are all in the same state.

@drgrice1
Copy link
Copy Markdown
Member Author

Hmm... I am seeing that too. I will look into it.

@drgrice1
Copy link
Copy Markdown
Member Author

That issue is fixed in openwebwork/mathquill#47.

@drgrice1
Copy link
Copy Markdown
Member Author

I went ahead and published @openwebwork/mathquill#47 to npm and added it to this branch (although that pull request is not merged into @openwebwork/mathquill yet). So you can test this pull request directly by just running npm ci.

Copy link
Copy Markdown
Contributor

@somiaj somiaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything I tested work now that the enable/disable is fixed.

@somiaj
Copy link
Copy Markdown
Contributor

somiaj commented May 27, 2026

I'll leave it to someone else to double check things via npm ci before merging.

@Alex-Jordan
Copy link
Copy Markdown
Contributor

I checked again with a fresh npm ci and it is all working, including with the newer Enable/Disable issue.

@Alex-Jordan Alex-Jordan merged commit d76f6c5 into openwebwork:PG-2.21 May 27, 2026
3 checks passed
@drgrice1 drgrice1 deleted the mathquill-internal-toolbar branch May 28, 2026 11:49
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.

3 participants