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

Replace django-ckeditor with django-tinymce #2324

Draft
wants to merge 11 commits into
base: dev
Choose a base branch
from
Draft

Replace django-ckeditor with django-tinymce #2324

wants to merge 11 commits into from

Conversation

bemoody
Copy link
Collaborator

@bemoody bemoody commented Jan 3, 2025

As we've discussed, PhysioNet's current rich text editor (CKEditor 4) is unmaintained and should be replaced. This branch replaces django-ckeditor with django-tinymce (https://github.com/jazzband/django-tinymce).

The user interface of TinyMCE is not too different from CKEditor 4. I've taken this opportunity, though, to try to tweak things to better serve PhysioNet's use cases. Notable changes include:

  • A toolbar button for adding <code> tags (also accessible via Ctrl+D.)

  • No toolbar buttons for <u>, <blockquote>, or <pre> tags (these styles are still accessible via the drop-down style menu.)

  • No toolbar buttons for adding/removing links (links can still be added using Ctrl+K.)

  • You can add italics, bold, code, equations, lists, and section headers using markdown-like syntax (*italics* becomes <em>italics</em>, etc.)

You'll see a warning if you try to navigate away or close the window without saving your changes. Also, content is auto-saved in local storage and can be restored by clicking the "Restore last draft" button at the end of the toolbar. Note that this does not import any auto-saved content from CKEditor.

@bemoody
Copy link
Collaborator Author

bemoody commented Jan 7, 2025

This breaks badly in old browsers: using Firefox 78, the editor mostly seems to work, but upon trying to save the form it crashes (which the user won't notice unless they are watching the console) and apparently submits blank content.

tinymce/tinymce#9557
tinymce/tinymce#9702
https://caniuse.com/css-not-sel-list

@tompollard
Copy link
Member

This breaks badly in old browsers: using Firefox 78, the editor mostly seems to work, but upon trying to save the form it crashes (which the user won't notice unless they are watching the console) and apparently submits blank content.

Can we raise a warning for people with old browsers or would you prefer to explore alternatives? From googling, the latest version of CKEditor is popular (though I'm sure it has its own issues).

@bemoody
Copy link
Collaborator Author

bemoody commented Jan 7, 2025

I'm certainly willing to look at alternatives & that's part of why I wanted to post this as a preview.

But it also should be possible to add a workaround (my thought was to fall back to a plain textarea on old unsupported browsers.)

@tompollard
Copy link
Member

But it also should be possible to add a workaround (my thought was to fall back to a plain textarea on old unsupported browsers.

Personally I'd rather just ask people using outdated browsers to update them!

@tompollard
Copy link
Member

tompollard commented Jan 30, 2025

I have had a quick play around with this. It seems to work, so I'm not against switching to TinyMCE. My main thoughts are:

1. Autosave

We appear to have lost the "auto-save" feature, which I think is fairly important for preventing people losing their work (e.g. when they accidentally go back on the browser or click on a tab withoutsaving).

Screenshot 2025-01-30 at 1 20 02 PM

2. Style

The new editor is slightly less visually appealing (for me, at least). It feels busy. Compare CKEditor:

Screenshot 2025-01-30 at 1 22 25 PM

Vs TinyMCE:

Screenshot 2025-01-30 at 1 21 55 PM

@bemoody
Copy link
Collaborator Author

bemoody commented Jan 31, 2025

Thanks!

Autosave

Certainly a valid concern. Worth checking out the official autosave plugin: https://www.tiny.cloud/docs/tinymce/latest/autosave/

(CKE5 has an autosave plugin too; like all CKE5 plugins, it requires recompiling the editor)

Cluttered appearance

You have a point. I think the cluttered feeling may be due in part to the autoresize behavior, which initially I thought was cool but now I'm less sure about. Try turning that off - comment out "autoresize" from the list of plugins, and compare.

If there are specific things you'd like to tweak, it shouldn't be hard to add a little custom CSS here and there.

@bemoody
Copy link
Collaborator Author

bemoody commented Feb 4, 2025

Worth checking out the official autosave plugin: https://www.tiny.cloud/docs/tinymce/latest/autosave/

This doesn't give the same UX as the autosave plugin we have been using, but I think it should be sufficient. It does two things:

  • if you've made changes, it warns you before leaving the page
  • it auto-saves content to local storage, which can later be restored by clicking a button

Keep in mind that this plugin won't import autosave data from the CKE4 autosave plugin.

@bemoody bemoody changed the title CKEditor to TinyMCE Replace django-ckeditor with django-tinymce Feb 5, 2025
@bemoody bemoody marked this pull request as ready for review February 5, 2025 19:36
@bemoody
Copy link
Collaborator Author

bemoody commented Feb 5, 2025

Ugh, modal boxes (source code, equation editor) are not working now. There's some bad interaction with other site scripts, probably bootstrap stuff. (TinyMCE works correctly inside Django admin.)

Something was already screwy before this - with CKE4, if CKE4 tries to "pop up" a modal box, then the page "underneath" the modal box scrolls back to the top, which is annoying. But now (after I added toolbar_sticky) the modal box itself is invisible.

@bemoody bemoody marked this pull request as draft February 5, 2025 21:47
@bemoody
Copy link
Collaborator Author

bemoody commented Feb 5, 2025

this:

html,body{height:100%; width: 100%;}
html{ overflow: overlay; }

Use the same backdrop color/opacity as Bootstrap modal dialogs.
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.

2 participants