tinyMCE-mention icon indicating copy to clipboard operation
tinyMCE-mention copied to clipboard

No longer works on tinymce 6.7

Open ghazpar opened this issue 1 year ago • 6 comments

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 ?

ghazpar avatar Nov 19 '23 04:11 ghazpar

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 avatar Dec 11 '23 06:12 mellevsen

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

mellevsen avatar Dec 13 '23 01:12 mellevsen

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.

mellevsen avatar Dec 13 '23 05:12 mellevsen

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

ghazpar avatar Dec 13 '23 15:12 ghazpar

I hope this helps others.

It does, thank you @mellevsen !

NicolasCARPi avatar Jan 14 '24 23:01 NicolasCARPi

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

CollapsedMetal avatar Mar 08 '24 16:03 CollapsedMetal