Skip to content

Simple-Token autocomplete not working in TinyMCE (HTML) #270

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

Closed
contaoacademy opened this issue Jul 20, 2022 · 6 comments
Closed

Simple-Token autocomplete not working in TinyMCE (HTML) #270

contaoacademy opened this issue Jul 20, 2022 · 6 comments

Comments

@contaoacademy
Copy link
Contributor

  • Notification Center 1.6.13
  • Contao 4.13.6
  • PHP 8.1

If I type ## in the RAW text-window, then autocomplete comes up automatically for me.
If I enable text and HTML and try to do the same in TinyMCE, then autocomplete does not show up.

Currently, I could only reproduce the problem under Contao 4.13 because under Contao 4.9 it still works as expected.

screen-20220720_4R2U26GF

@cliffparnitzky
Copy link
Contributor

Can confirm. The developer console throws an error.

@contaoacademy
Copy link
Contributor Author

Maybe the same issue as #262

@philvdb
Copy link
Contributor

philvdb commented Jul 26, 2022

@contaoacademy possibly, but the behavior is slightly different. TinyMCE does not load for me at all when I use Contao 4.13.

@philvdb
Copy link
Contributor

philvdb commented Jul 26, 2022

Now that my tinyMCE is showing again I was able to look into the autosuggester problem. I'm not familiar with tinyMCE at all but the problem seems to be in assets/autosuggester.js:164:

        // Add the events to tinyMCE
        if (this.tinyMCE) {

            if (window.tinyMCE.majorVersion == '4') {
                this.tinyMCE.on('keyUp', function(event) {
                   this.eventKeyUp.call(this, event);
                }.bind(this));

window.tinyMCE is not defined, this.tinyMCE is. However, this.tinyMCE does not have a property called majorVersion or version at all at least in my installation. This means that the check for version 4 fails and the nonexistent property onKeyUp causes the error in our developer consoles.

Knowing virtually nothing about tinyMCE I don't know if this is the proper solution. However at least in my installation, instead of looking for the version number checking for the existence of the on function leads to the autosuggester working again:

        // Add the events to tinyMCE
        if (this.tinyMCE) {

            if (typeof this.tinyMCE.on === 'function') {
                this.tinyMCE.on('keyUp', function(event) {
                   this.eventKeyUp.call(this, event);
                }.bind(this));

Let me know if this is the right approach I could try creating a pull request .. would have to figure out how to minify the Javascript properly though 🤡 . If switching out the line and minifying the JS is something that comes easy in your development workflow I will be happy if anyone else wants to do it.

@philvdb
Copy link
Contributor

philvdb commented Jul 27, 2022

@contaoacademy , @cliffparnitzky feel free to try out https://github.com/philvdb/contao-notification_center to see whether it solves the problem for you as well and report back here.

@contaoacademy
Copy link
Contributor Author

@philvdb Looks great! Works for me. Thank you.

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

No branches or pull requests

3 participants