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

[BB-6151] feat: upgrades tinyMCE v4.0.20 to tinyMCE v5.5.1 #30335

Merged
merged 14 commits into from
Sep 19, 2022

Conversation

DubeySandeep
Copy link
Contributor

@DubeySandeep DubeySandeep commented Apr 29, 2022

Description

This PR upgrades TinyMCE version 4 to version 5.5.1.

These changes will impact the "Course author".

Supporting information

Testing instructions

Testing new TinyMCE in Studio

  1. Run the studio server from devstack dir “make studio-up”
  2. Login to studio and create a new course.
  3. Add a new unit in the course and go to the unit editor page.
  4. Click “HTML” component button and select “Text”.
  5. Click the component to edit, this will show a modal containing “tinymce” editor.
  6. Use the TinyMCE editor thoroughly to test all the features.
  7. Save the changes and expect it to get saved and loads correctly after refreshing the page.

Ensure the “visual” and “raw” html editor are working fine

  1. Run the studio server from devstack dir “make studio-up”
  2. Login to studio and create a new course.
  3. Add a new unit in the course and go to the unit editor page.
  4. Click “HTML” component button and select “Raw”.
  5. Click the component to edit, this will show a modal containing “codemirror” editor.
  6. Click the “setting-icon” in the editor modal and change the “Editing mode” to “visual”.
  7. Click the component to edit, this will show a modal containing “tinyMce” editor.

Ensure the “codemirror-plugin” works fine in the tinymce editor

  1. Run the studio server from devstack dir “make studio-up”
  2. Login to studio and create a new course.
  3. Add a new unit in the course and go to the unit editor page.
  4. Click “HTML” component button and select “Text”.
  5. Click the component to edit, this will show a modal containing “tinymce” editor.
  6. Click on “HTML” icon on the toolbar of the editor, this will show a modal with codemirror editor.
  7. Add some HTML content and save the changes.
  8. The saved changes should show up in the TinyMCE editor.

Testing announcements message in studio

  1. Run the studio server from devstack dir “make studio-up”
  2. Go to “/maintenance” and select “announcement” section.
  3. Click “Create new announcement” button.
  4. The TinyMCE editor will show up, make sure to test all the components in the editor.
  5. Save the announcement message.

Screenshots and videos of UI changes

Video comparing TinyMCE4 and TinyMCE5 in studio

TinyMCE4_vs_TinyMCE5.mp4

OLD TinyMCE UI in Studio

image

NEW TinyMCE UI in Studio

image

OLD TinyMCE UI on announcement editor page

image

NEW TinyMCE UI on announcement editor page

image

@openedx-webhooks openedx-webhooks added needs triage open-source-contribution PR author is not from Axim or 2U labels Apr 29, 2022
@openedx-webhooks
Copy link

openedx-webhooks commented Apr 29, 2022

Thanks for the pull request, @DubeySandeep! Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket as you can:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

Copy link
Contributor Author

@DubeySandeep DubeySandeep left a comment

Choose a reason for hiding this comment

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

(Leaving some inline comments to explain the changes to reviewer.)

codemirror: {
path: baseUrl + "js/vendor"
path: baseUrl + "js/vendor",
disableFilesMerge: true,
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 new codemirror plugin allows passing the custom jsFiles to the plugin. Earlier we had to change the plugin code (ref)

theme: "modern",
skin: 'studio-tmce4',
theme: "silver",
skin: "studio-tmce5",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

"studio-tmce5" is the new skin created having similar colour and style of "studio-tmce4" (Note: The custom-skin structure is completely changed in v5 so we had to regenerate the new skin from scratch.)

"alignleft aligncenter alignright alignjustify | " +
"bullist numlist outdent indent blockquote | link unlink " +
((this.new_image_modal ? 'insertImage' : 'image') + " | code"),
toolbar: "formatselect fontselect bold italic underline forecolor wrapAsCode " +
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Although we have used | here but we had disabled the "bars" in the studio-tmce4 skin but disabling the "bars" is not possible in the new skin so ended up remving "|" to achieve the old UI.

Copy link
Member

@Agrendalath Agrendalath May 5, 2022

Choose a reason for hiding this comment

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

It's also worth noting that these separators are redundant now. The only thing they were doing before, was wrapping the toolbar items in groups. I.e. if a button from a single group should be moved to a lower row (due to insufficient width of the editor), then the whole group is moved there instead.

It is no longer the case because the default toolbar modes have been changed to more user-friendly options. The PC version is using the floating toolbar, but for this to happen, a browser's window width would need to be under 1024px. On mobile devices, the overflow is handled by scrolling.

image: baseUrl + "images/ico-tinymce-code.png",
onclick: function() {
tooltip: gettext('Code block'),
icon: 'code-sample',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TinyMCE5 only allows svg icons and have different way to add new icon (ref), overe here we are using a builtin icon.

Old png icon: { }
New svg icon (code-sample): { ; }

(Check screenshot in the PR description for UI)

@natabene
Copy link
Contributor

natabene commented May 3, 2022

@DubeySandeep Thank you for your contribution. Is this ready for our review?

@openedx-webhooks openedx-webhooks added waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. and removed needs triage labels May 3, 2022
@jmyatt
Copy link
Contributor

jmyatt commented May 5, 2022

@jmbowman @jristau1984 as this change affects Studio as opposed to the LMS, maybe it should be reviewed by TNL?

@Agrendalath Agrendalath force-pushed the DubeySandeep/tinymce_upgrade branch from 1d4dff0 to 9201eb2 Compare May 5, 2022 21:30
@DubeySandeep
Copy link
Contributor Author

@natabene Thanks for checking! Yeah, the PR is ready for review, I've asked @Agrendalath to take the first pass (as an internal reviewer) and I'll be happy to get feedback/suggestion from other reviewers! :)

Copy link
Member

@Agrendalath Agrendalath left a comment

Choose a reason for hiding this comment

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

@DubeySandeep, I've tested that this is working correctly with both announcements and HTML XBlock. I've checked the HTML XBlock in the Studio unit view, the custom pages view, and the bulk email section of the Instructor Dashboard.

Could you please look into this failing JS test?

"alignleft aligncenter alignright alignjustify | " +
"bullist numlist outdent indent blockquote | link unlink " +
((this.new_image_modal ? 'insertImage' : 'image') + " | code"),
toolbar: "formatselect fontselect bold italic underline forecolor wrapAsCode " +
Copy link
Member

@Agrendalath Agrendalath May 5, 2022

Choose a reason for hiding this comment

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

It's also worth noting that these separators are redundant now. The only thing they were doing before, was wrapping the toolbar items in groups. I.e. if a button from a single group should be moved to a lower row (due to insufficient width of the editor), then the whole group is moved there instead.

It is no longer the case because the default toolbar modes have been changed to more user-friendly options. The PC version is using the floating toolbar, but for this to happen, a browser's window width would need to be under 1024px. On mobile devices, the overflow is handled by scrolling.

common/static/js/vendor/tinymce/BUILD_README.txt Outdated Show resolved Hide resolved
Comment on lines 6 to 7
4. Find all the EDX specific changes in the currently used version of tinymce by searching for the string "EDX" in the vendor/js/tinymce dir.
5. Merge the EDX specific changes with the newly downloaded version.
Copy link
Member

@Agrendalath Agrendalath May 5, 2022

Choose a reason for hiding this comment

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

Just for better visibility during the review. We have only two overrides - one in plugins/codemirror/source.html and one in js/tinymce/plugins/codemirror/plugin.js. Is it correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's true!
image

2. Open terminal and change directory to the newly downloaded tinymce.
3. Run the build command: “yarn build”, this will create multiple zip files in the build directory.
4. Unzip the tinymce_<version>.zip file in common/static/vendor/js/
5. Unzip vendor_extra/tinymce/JakePackage.zip in common/static/vendor/js/tinymce/.
Copy link
Member

Choose a reason for hiding this comment

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

I believe it's common/static/js/vendor/tinymce/,

Also, is there a specific reason to use js/vendor/tinymce/js/tinymce instead of just js/vendor/tinymce?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, is there a specific reason to use js/vendor/tinymce/js/tinymce instead of just js/vendor/tinymce?

the common/static/js/vendor/ is the open-edx structure for storing vendor files where as js/tinymce/ is the tinymce's structure (the js dir contains other files like README, packge.json etc.).

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 believe it's common/static/js/vendor/tinymce/,

Yeah, that's true! I've updated the instructions.

Copy link
Member

Choose a reason for hiding this comment

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

where as js/tinymce/ is the tinymce's structure

I couldn't find any references to this structure in TinyMCE or CodeMirror, but I see that it's referenced like this in multiple places within the edx-platform, so let's keep it as-is for backward compatibility.

(the js dir contains other files like README, packge.json etc.).

I don't see other files in vendor/tinymce/js, but I suppose that keeping BUILD_README.txt in a separate directory increases its visibility 👍

@natabene
Copy link
Contributor

natabene commented May 6, 2022

Owning team will want to have a look at this before merging, since they are actively working in this area.

@tecoholic
Copy link
Contributor

@Agrendalath This was a doozy. I finally traced it to a race condition in the tests where data was being queried before TinyMCE has finished initializing. I have update the tests, to wait until init is complete before testing. Kindly review.

@@ -1406,7 +1410,7 @@
if (this.editor_choice === 'visual') {
visualEditor = this.getVisualEditor();
raw_content = visualEditor.getContent({
format: "raw",
format: "text",
Copy link
Contributor

Choose a reason for hiding this comment

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

TinyMCE 5 uses the value text instead of raw for the format.

Copy link
Member

@Agrendalath Agrendalath left a comment

Choose a reason for hiding this comment

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

👍

  • I tested this: checked that it is working correctly with both announcements and HTML XBlock; checked the HTML XBlock in the Studio unit view, the custom pages view, and the bulk email section of the Instructor Dashboard.
  • I read through the code
  • I checked for accessibility issues
  • Includes documentation
  • I made sure any change in configuration variables is reflected in the corresponding client's configuration-secure repository: n/a

common/lib/xmodule/xmodule/js/spec/html/edit_spec.js Outdated Show resolved Hide resolved
@Agrendalath
Copy link
Member

@natabene, this is ready for your review.

Copy link
Member

@Agrendalath Agrendalath left a comment

Choose a reason for hiding this comment

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

We found some regressions that cannot be reproduced locally. I'm converting it to a draft for now.

@Agrendalath Agrendalath marked this pull request as draft May 26, 2022 01:38
@tecoholic
Copy link
Contributor

tecoholic commented Jun 3, 2022

@Agrendalath I have added the commit 49e3309 with the fix for editor breaking on Studio. The minified version of the TinyMCE doesn't seem to play well with the optimized builds of webpack. Once I switched out the minified to a non-minified version in the Webpack configuration and redid a optimized build, things started to work fine.

Another side-effect I noticed is that the size of the container.js file dropped drastically. Using the larger input file actually provides a smaller output file. Something to do with tree-shaking I guess.

Before - using tinymce.full.min.js - 2.2MB

min-js-size

After - using the tinymce.js - 1.4MB

non-min-js

@Agrendalath Agrendalath marked this pull request as ready for review June 4, 2022 16:39
@openedx-webhooks openedx-webhooks added needs triage and removed waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. labels Jun 4, 2022
@Agrendalath Agrendalath force-pushed the DubeySandeep/tinymce_upgrade branch from 49e3309 to ada8e9f Compare June 4, 2022 16:50
@natabene
Copy link
Contributor

natabene commented Jun 6, 2022

@Agrendalath Please let me know if this is ready.

@Agrendalath
Copy link
Member

@tecoholic, I deployed this to the production-like environment (which is using a CDN) and noticed that we have missed the following change: 9c1a42b.

We need to check if there is something else missing from here: #3155.

@tecoholic
Copy link
Contributor

tecoholic commented Jun 8, 2022

@Agrendalath I have made the necessary changes to get the iframe communication working in TinyMCE in 1ed35b7. But I am afraid the work is far from being done.

  1. While testing I noticed that the Open Response Assessment block is crashing when the editor is set to WYSIWYG. Tried debugging for almost an hour and for some reason I can't find the source file. Let me know if you have some insights into this.
  2. While the reference commit removes the plugin.min.js file in favour of JS build tool, I am afraid the tools have changed since then and it's no longer automatically done. The instructions related to this in BUILD_README.txt is of no help and I am sure, are completely wrong after the current commit, as it will discard the changes. For the current commit, I manually used esbuild to minify the plugin file and added it to the commit. - DONE at 8de9e66
  3. The CodeMirror files are compressed into a single file, but currently the source.html file references them individually. So that needs to be changed. This is a small change I will probably get this done first. - Done at eaaccc9

Let's move this to draft until we wrap all of this up.

@tecoholic tecoholic force-pushed the DubeySandeep/tinymce_upgrade branch from a11b3e1 to 8d49e28 Compare June 9, 2022 13:19
@tecoholic
Copy link
Contributor

@Agrendalath Rebased on master and resolved conflicts.

Copy link
Member

@Agrendalath Agrendalath left a comment

Choose a reason for hiding this comment

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

All good from my end. Linking my review: #30335 (review)

@Agrendalath Agrendalath merged commit 51b5e62 into openedx:master Sep 19, 2022
@Agrendalath Agrendalath deleted the DubeySandeep/tinymce_upgrade branch September 19, 2022 10:43
@openedx-webhooks
Copy link

@DubeySandeep 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future.

@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production.

@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production.

@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

Agrendalath pushed a commit to open-craft/edx-ora2 that referenced this pull request Oct 7, 2022
…rsion 5.x (openedx#1869)

* feat: replace references to tinymce v4 with v5

Replaces the version 4.x references of TinyMCE static files with version 5.x
and removes the workaround required for TMCE 4 from oa_editor_tinymce.js

Related platform PR: openedx/edx-platform#30335

Related changes:

* fix: set tinymce base url so resources are loaded in studio
* fix: theme files not loading on studio edit window
* chore: bumped minor version to 4.5.0
* chore: update edx paragon to latest version, and fix failing tests due to paragon api change
* fix: fix and update translations

Co-authored-by: Agrendalath <piotr@surowiec.it>

(cherry picked from commit 6072196)
Agrendalath pushed a commit to open-craft/edx-platform that referenced this pull request Oct 7, 2022
Co-authored-by: Arunmozhi <arunmozhi@opencraft.com>

(cherry picked from commit 51b5e62)
Agrendalath pushed a commit to open-craft/edx-platform that referenced this pull request Oct 7, 2022
Co-authored-by: Arunmozhi <arunmozhi@opencraft.com>

(cherry picked from commit 51b5e62)
GlugovGrGlib pushed a commit to raccoongang/edx-platform that referenced this pull request May 29, 2024
Recent upstream changes to Olive include deletion of the "modern"
theme we've used for the TinyMCE initialization for the course overview
field in the Studio course Schedule and Details page.

The fix: use the "silver" theme added in the same PR the "modern" theme was removed.

Check [this PR](openedx#30335)
for details.

YT: https://youtrack.raccoongang.com/issue/RGOeX-25023
a-kryachko pushed a commit to raccoongang/edx-platform that referenced this pull request Jun 14, 2024
Recent upstream changes to Olive include deletion of the "modern"
theme we've used for the TinyMCE initialization for the course overview
field in the Studio course Schedule and Details page.

The fix: use the "silver" theme added in the same PR the "modern" theme was removed.

Check [this PR](openedx#30335)
for details.

YT: https://youtrack.raccoongang.com/issue/RGOeX-25023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-source-contribution PR author is not from Axim or 2U
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

9 participants