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

Fix tinymce on-demand loading #18105

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cconard96
Copy link
Contributor

Checklist before requesting a review

  • I have read the CONTRIBUTING document.
  • I have performed a self-review of my code.

Description

TinyMCE is currently loaded in two ways:

  • Sector-based inclusion
  • On-demand just before initializing the editor on a textarea

Neither of these cases are very good.

The first case technically works, but there can be some cases where the library is loaded for no reason. For example, it was included for the central page but its only ever actually used if you click on an event in the planning widget which loads the Reminder/Event form in a modal. If you don't actually initialize an editor, you have a 680kb script (non-minified size) being loaded for nothing.

The second case makes more sense, except that it doesn't actually load the library if initialized any time after includeHeader is called because initEditorSystem calls requireJs. Instead, it adds the library to the session property and would have it automatically load the next time includeHeader is called (page refresh). This is how you end up with bugs like #3663. The solution for the referenced issue was to just load the library for the entire central sector which is more of a workaround than addressing the actual issue.

You could directly import the required scripts by adding script tags with the src attribute set inside initEditorSystem, but that would load them multiple times if there are multiple editors.

The solution here is to move the initialization into its own script which imports the extra JS files and then use dynamic imports to ensure the module is only loaded once but still allows initializing multiple editors.

@cconard96 cconard96 force-pushed the fix/tinymce_ondemand branch from 92602a4 to d70ed2a Compare October 20, 2024 22:54
@cconard96 cconard96 changed the base branch from 10.0/bugfixes to main October 20, 2024 23:23
@cconard96 cconard96 force-pushed the fix/tinymce_ondemand branch from c8015f1 to a8057d6 Compare October 23, 2024 14:02
@cconard96 cconard96 marked this pull request as ready for review October 23, 2024 19:59
src/Html.php Outdated Show resolved Hide resolved
Copy link
Contributor

@trasher trasher left a comment

Choose a reason for hiding this comment

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

See @AdrienClairembault comment

Copy link
Contributor

@AdrienClairembault AdrienClairembault left a comment

Choose a reason for hiding this comment

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

Placeholder styles seems to not be fully loaded.

On main:
image

With your changes:
image

There are a lot of extra padding and the text color isn't right.

edit: the cursor seems also wrong, it not longer have the text appearance.

Copy link
Contributor

@AdrienClairembault AdrienClairembault left a comment

Choose a reason for hiding this comment

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

It seems to now work for some placeholders but not all:

image

In this example the second one doesn't have the correct color.

Padding issues seems to be mostly resolved, there is still some additional left padding that seems to be applied when compared to main but I can live with it.

Nevertheless, maybe it mean the styles are not fully charged so it might be worth investigating because there might be other issues that we may miss here.

@cconard96 cconard96 force-pushed the fix/tinymce_ondemand branch 2 times, most recently from 8afbf96 to 2139d64 Compare January 14, 2025 23:29
@cconard96
Copy link
Contributor Author

I've reverted back to the oxide skin to unblock this PR. I'll work on fixing it in a different PR.

src/Html.php Outdated Show resolved Hide resolved
Copy link
Member

@cedric-anne cedric-anne left a comment

Choose a reason for hiding this comment

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

Tests are still failing.

@cconard96 cconard96 force-pushed the fix/tinymce_ondemand branch from 63bdf23 to 5d79354 Compare January 23, 2025 00:35
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.

4 participants