Skip to content

Conversation

@michaelchadwick
Copy link
Contributor

Fixes ilios/ilios#6353

The Quill is mightier than the Froala, or something.

Still have a hojillion tests to fix, but this is a Proof of Concept that works pretty well as a replacement. The only thing I still need to add, feature-wise, is a more dynamic, local CSS load (it's currently global on the index.html file), and the pre-chosen links for Insert Link.

Feel free to mess around with it and find where it breaks!

@netlify
Copy link

netlify bot commented Aug 4, 2025

Deploy Preview for ilios-frontend ready!

Name Link
🔨 Latest commit 1b47120
🔍 Latest deploy log https://app.netlify.com/projects/ilios-frontend/deploys/68cc80d7c1403c0007c70ce3
😎 Deploy Preview https://deploy-preview-8739--ilios-frontend.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Member

@dartajax dartajax left a comment

Choose a reason for hiding this comment

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

The "undo" button should not be activated unless the user has made a change.

@dartajax
Copy link
Member

dartajax commented Aug 4, 2025

This is our current froala config with the inactive undo and redo buttons up higher on the same level as Bold, Italic and the other controls - also with the white background rather than blue.

image image

In my testing, undo using Quill erases the entirety of the text entered, which could be disastrous if "saved".

@michaelchadwick
Copy link
Contributor Author

@dartajax the blue background and undo/redo issues should be fixed.

@jrjohnson I also threw in the "hide insert link popup if you click away from it" fix.

@michaelchadwick michaelchadwick marked this pull request as ready for review August 6, 2025 18:25
Copy link
Member

@jrjohnson jrjohnson left a comment

Choose a reason for hiding this comment

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

Some code changes, two behavior things I noticed:

  1. Needs to expand to fill full space:
    Froala:
Image

Quill:

Image

And when the add link popup is open it's hard to close. Needs a x button to click, but I think escape in the input should also close it. Clicking outside works, that's nice.

}
export async function quillEditorValue(element) {
const editor = await getEditorInstance(element);
return editor.root.innerHTML.split(' ').join(' &nbsp;').replaceAll('<p><br></p>', '');
Copy link
Member

Choose a reason for hiding this comment

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

This needs a comment or link. I'm guessing this is the only way to get at the value here, but it seems weird to reach into the HTML and that there isn't an API in quill to get the current value of the editor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a call to get the contents: https://quilljs.com/docs/api#getcontents, but it doesn't work as well as what I used.

There are three ways to get at what's in the editor (I had just added the exclamation point at the end):
Screenshot 2025-08-11 at 1 13 41 PM

if (!this.isDestroyed && !this.isDestroying) {
this.editorHasNoRedo = !this.editor.history.stack.redo.length;
this.editorHasNoUndo = !this.editor.history.stack.undo.length;
// make sure to retain multiple spaces
Copy link
Member

Choose a reason for hiding this comment

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

I agree this is what the code does, but maybe a deeper comment on why is needed? Why not just let quill collapse spaces?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason for this code is because Froala also retains multiple spaces, but Quill needs this extra bit to achieve parity.

export async function loadQuillEditor() {
const { default: QuillEditor } = await import('quill');

// Quill doesn't include redo/undo icons by default, so gotta hack 'em in
Copy link
Member

Choose a reason for hiding this comment

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

Could we use what's in font awesome for this? I'm not worried about style yet, but I don't love carrying some random SVG stuff here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried Fontawesome but the icons don't match the rest of the toolbar buttons.

The <svg> markup is not random, as it comes from Quill itself: node_modules/quill/assets/icons/[undo|redo].svg. Why this isn't wired up already, I do not know (nor does anyone else using Quill that I could find). Perhaps an upstream PR is needed?

I put a comment in the code about this, and reproduced the link I followed here so you know where this method came from: slab/quill#885 (comment)

Copy link
Member

Choose a reason for hiding this comment

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

Ah, how about we pull this svg out of node_modules and into /public and use it directly? My objection is just to the svg in the code that's a little bit hard to figure out where it's from or when to update it.

@michaelchadwick michaelchadwick force-pushed the frontend-6353-replace-froala-with-quill branch from b6a3c7f to 13aadd4 Compare August 11, 2025 19:50
@michaelchadwick
Copy link
Contributor Author

@jrjohnson Editor instance now fills container, and link popup closes on escape key. Froala doesn't currently have an 'X'-type close button, so I didn't think to add it to Quill. However, it could be added.

@michaelchadwick michaelchadwick force-pushed the frontend-6353-replace-froala-with-quill branch from 1f80596 to 7caa346 Compare August 14, 2025 22:27
@michaelchadwick
Copy link
Contributor Author

@jrjohnson The best thing I came up with so far for loading the redo/undo svg files is here 1f80596

@michaelchadwick michaelchadwick force-pushed the frontend-6353-replace-froala-with-quill branch from 7caa346 to ebb89eb Compare August 15, 2025 22:23
@jrjohnson
Copy link
Member

I'm good with the fetch process. Works for me. Waiting for tests to pass, but I'm all in favor. Think it's worth a second review from @stopfstedt as well.

@michaelchadwick michaelchadwick force-pushed the frontend-6353-replace-froala-with-quill branch 2 times, most recently from d9af9eb to 5119b38 Compare August 25, 2025 15:09
Copy link
Member

@stopfstedt stopfstedt left a comment

Choose a reason for hiding this comment

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

code reviewed and click-tested. LGTM.

Copy link
Member

@dartajax dartajax left a comment

Choose a reason for hiding this comment

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

A couple of thing regarding inserting links ... I will put them in separate comments though. Here's one thing I noticed.

image

@dartajax
Copy link
Member

https://deploy-preview-8739--ilios-frontend.netlify.app/courses/2318/sessions/nytimes.com

I inserted the link "nytimes.com" into a session description field. The URL above will always get you zoinked.

@michaelchadwick
Copy link
Contributor Author

@dartajax I added in some logic to hopefully turn protocol-less links like that into protocol-rich links.

@michaelchadwick
Copy link
Contributor Author

@dartajax the "Open in new tab" option was initially put in there, unchanging, because Quill doesn't have a mechanism to put a link in without opening a new tab/window. However, I wanted to make the dialog with as much parity to Froala as possible.

That being said, I could spend more time trying to reverse engineer their logic and make that toggle work, or I could just remove it entirely and the User Guide could mention the change from Froala to Quill.

@michaelchadwick michaelchadwick force-pushed the frontend-6353-replace-froala-with-quill branch from f51ae84 to 23ca15e Compare August 26, 2025 17:49
@michaelchadwick
Copy link
Contributor Author

Look into adding the link target toggle functionality.

@michaelchadwick
Copy link
Contributor Author

@dartajax I added the functionality to make a link open in a new tab or not, so that's taken care of. Please give it a whirl to make sure it works. Still need to add tests, though.

Copy link
Member

@dartajax dartajax left a comment

Choose a reason for hiding this comment

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

I will leave this one as a comment rather than a change request although it may end up being that as well.

There may be a few of these also as I have noticed some issues.

This is in Froala ...

image

After clicking the edit link (as shown above), you get the following ...

image

With Quill what happens? ...

image

Click edit as shown above ...

The only thing that can be edited is the link itself and not whether it opens in a new tab or what the text display value is. Froala allows for editing of this information.

But it gets worse or weirder. When you click "Save" ...

image

After clickiing "Save" as shown above ...

Return to the link and see this ...

image

It is true if you cancel the operation and don't save any changes, the original link will still be there but there may be other text changes that needed to be made and that should not cause the link to be erased.

…t figure out how to access quill internal object
@michaelchadwick
Copy link
Contributor Author

@dartajax Do you want me to work further on the Word document copy/paste minor discrepancy?

@jrjohnson
Copy link
Member

This may be unrelated, but I see siteimprove is picking up Role with implied hidden content has keyboard focus on a demo quill edit link when it's within our expanding text widget. I'm wondering if something about the HTML output is slightly different and now triggering an error where we haven't had one before.

@michaelchadwick michaelchadwick force-pushed the frontend-6353-replace-froala-with-quill branch from 3774c2f to 1b47120 Compare September 18, 2025 21:59
@dartajax dartajax added the run ui tests Run the expensive UI tests label Sep 18, 2025
@dartajax dartajax merged commit 065e2a4 into ilios:master Sep 18, 2025
38 checks passed
@michaelchadwick michaelchadwick deleted the frontend-6353-replace-froala-with-quill branch September 19, 2025 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run ui tests Run the expensive UI tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

explore replacing Froala with Quill as our WYSIWYG editor

4 participants