Skip to content
This repository has been archived by the owner on Mar 9, 2024. It is now read-only.

TinyMCE in Text Widget #273

Closed
KTS915 opened this issue Oct 31, 2023 · 3 comments
Closed

TinyMCE in Text Widget #273

KTS915 opened this issue Oct 31, 2023 · 3 comments
Labels
good first issue Good for newcomers and experienced contributors alike! status: in-progress When an issue or PR is being worked on now. type: bug Something isn't working

Comments

@KTS915
Copy link
Member

KTS915 commented Oct 31, 2023

Expected behavior

Is TinyMCE supposed to be working in the Text widget? I don't use it normally but, as I'm working on something to do with widgets, I had cause to test it and found that Tiny doesn't work. (In fact, there's an error generated in the browser console.)

Current behavior

When opening a Text widget, the user can enter blank text only. There is no TinyMCE editor.

Possible solution

What's missing are some lines in the ~/wp-includes/script-loader.php file and then some lines in the ~wp-admin/js/widgets/text-widgets.js file.

I can provide a PR if we agree that Tiny is supposed to be working (which I think is what we want). If we don't want that, then some lines need removing from the ~wp-admin/js/widgets/text-widgets.js file to avoid generating the current error.

Steps to reproduce bug

Open a Text widget and see for yourself.

Context

No response

ClassicPress version

2.0.0+nightly.20231005

PHP version

8.1

Can you help?

Yes, I will submit a PR

@KTS915 KTS915 added status: needs triage This issue needs revision, splitting, or other gardening work type: bug Something isn't working labels Oct 31, 2023
@mattyrob mattyrob added good first issue Good for newcomers and experienced contributors alike! status: in-progress When an issue or PR is being worked on now. and removed status: needs triage This issue needs revision, splitting, or other gardening work labels Oct 31, 2023
@mattyrob
Copy link
Collaborator

Agreed, something looks incorrect here, I cant even get Text widgets to work fully nor errors to show locally. I think it should be using TinyMCE if you are happy to submit a PR @KTS915

@mattyrob
Copy link
Collaborator

mattyrob commented Nov 1, 2023

I've been trying to test the PR #275 for this and couldn't get things working locally at all, until I reverted the changes we made in #240 - reversing that entire commit popped the TinyMCE editor back into existence for me on Text Widgets.

Does that help in figuring this issue out? Is it worth reverting #240 and re-working that PR again? Would accept your suggestion here.

@KTS915
Copy link
Member Author

KTS915 commented Nov 2, 2023

I've just made one more change to PR #275. It seems that the previous changes have made everything so much quicker that it was just happening too fast for TinyMCE! So I have increased the delay before it goes to work from 50ms to 200ms. (I tried 100ms and it was inconsistent as to whether that was enough, so 200 seems safe). I think we should be good now.

mattyrob added a commit that referenced this issue Nov 10, 2023
* Update script-loader.php to include scripts required to run TinyMCE in the text widget

See Issue #273

* Update text-widgets.js to run TinyMCE editor

* Update script-loader.php to remove unrelated code

* Update text-widgets.js to add TinyMCE bypasses

* Update text-widgets.js

This uses a combination of vanilla JS and jQuery, but that's what the widget uses already. (Yes, the code we've inherited here is a real dog's breakfast.) At a later date we can work on replacing this with purely vanilla JS once we have it all working.

This still leaves one thing not working correctly. If two Text widgets are added in the Customizer, the second won't open; that probably needs a fix in a different file. I will investigate.

* Coding standards fix

* Update script-loader.php in response to #275 (review)

* Update text-widgets.js

* Update customize-widgets.js to make TinyMCE work for all Text widgets in Customizer

* Update text-widgets.js to delay instantiating TinyMCE for 200ms

* Update widgets.css to prevent widgets expanding beyond container

---------

Co-authored-by: mattyrob <[email protected]>
@KTS915 KTS915 closed this as completed Nov 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Good for newcomers and experienced contributors alike! status: in-progress When an issue or PR is being worked on now. type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants