mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-17 06:18:44 +02:00
🐛 N°4834 - Fix mentions working only with latin alphabet (no dash, no cyrillic, no asian, ...) (#274)
* 🐛 Add the 'pattern' parameter with the unicode Cyrillic block regex to the CKEditor mentions config.
* Revert "🐛 Add the 'pattern' parameter with the unicode Cyrillic block regex to the CKEditor mentions config."
This reverts commit 1f5ac000b6.
* 🐛 Rewrite the CKEditor Mentions plugin regexp to make it suitable for all Unicode alphabets.
This commit is contained in:
@@ -21,3 +21,24 @@ if ((CKEDITOR !== undefined) && (CKEDITOR.plugins.registered['disabler'] === und
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
// Rewrite the CKEditor Mentions plugin regexp to make it suitable for all Unicode alphabets.
|
||||
if (CKEDITOR !== undefined && CKEDITOR.plugins.registered['mentions']) {
|
||||
// from https://github.com/ckeditor/ckeditor4/blob/a3786007fb979d7d7bff3d10c34a2d422935baed/plugins/mentions/plugin.js#L147
|
||||
function createPattern(marker, minChars) {
|
||||
let pattern = marker + '[\\p{L}\\p{N}_-]';
|
||||
if ( minChars ) {
|
||||
pattern += '{' + minChars + ',}';
|
||||
} else {
|
||||
pattern += '*';
|
||||
}
|
||||
pattern += '$';
|
||||
return new RegExp(pattern, 'u');
|
||||
}
|
||||
|
||||
CKEDITOR.on('instanceLoaded', event => {
|
||||
event.editor.config.mentions.forEach(config => {
|
||||
config.pattern = createPattern(config.marker, config.minChars);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user