StevenDevooght / tinyMCE-mention

Mention/Autocomplete plugin for tinyMCE WYSIWYG editor.
http://stevendevooght.github.io/tinyMCE-mention/
220 stars 95 forks source link

No longer works on tinymce 6.7 #93

Open ghazpar opened 9 months ago

ghazpar commented 9 months ago

I've been using this plugin for several years without any problem (with tinymce 5 and 6), but it recently stopped working. I've noticed it a few days ago; not sure exactly when it stopped working. Anyway, the current tinymce version is 6.7.3.

The problem seems to be located in the call to the source function. The function is called, but its 1st argument, the query, is always an empty string, so there is nothing to search for.

I guess something must have changed in tinymce, and this change has broken the plugin ?

Anyone has a clue on how to fix this ?

mellevsen commented 8 months ago

I'm getting the same symptom with TinyMCE Version: 5.10.9 (2023-11-15).

In my case too, the query is always an empty string. Haven't yet figured out a hack.

mellevsen commented 8 months ago

TinyMCE Version: 5.10.8 (2023-10-19) works fine, so defect was injected with TinyMCE v5.10.9.

mellevsen commented 8 months ago

I have a fix.

CAUSE: TinyMCE v5.10.9 and v6.7.3 explicitly changed how the "zero width no-break space" character(U+FEFF) is handled. Unfortunately, the mention plugin uses U+FEFF as a delimiter for the user-entered search text.

SOLUTION: Change the U+FEFF character to U+200B ("zero width space") in the 2 places it is used. Here's the affected lines.

OLD

# 67: '<span id="autocomplete-searchtext"><span class="dummy">\uFEFF</span></span>' +
#187: this.query = $.trim($(this.editor.getBody()).find('#autocomplete-searchtext').text()).replace('\ufeff', '');

NEW

# 67: '<span id="autocomplete-searchtext"><span class="dummy">\u200b</span></span>' +
#187: this.query = $.trim($(this.editor.getBody()).find('#autocomplete-searchtext').text()).replace('\u200b', '');

The line numbers reference the un-minimized plugin of course, so you'll also need to make equivalent changes in the minimized version. I'll open a pull request, although I'm not sure whether it'll ever be merged as this plugin seems to no longer be actively maintained.

I hope this helps others.

ghazpar commented 8 months ago

Yes, this easy fix has brought back the functionality. Thank you!

NicolasCARPi commented 7 months ago

I hope this helps others.

It does, thank you @mellevsen !

CollapsedMetal commented 5 months ago

Fixed the project to work with tinymce 6.x Checkout my PR #96