From 03e2de077b370cd87eb47cdda857b9f3b63668b6 Mon Sep 17 00:00:00 2001 From: Maksim Sukharev Date: Tue, 19 Nov 2024 10:54:14 +0100 Subject: [PATCH] fix(NcRichContenteditable): support email mentions Signed-off-by: Maksim Sukharev --- src/mixins/richEditor/index.js | 2 +- tests/unit/mixins/richEditor.spec.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mixins/richEditor/index.js b/src/mixins/richEditor/index.js index 0401698474..a623acca31 100644 --- a/src/mixins/richEditor/index.js +++ b/src/mixins/richEditor/index.js @@ -15,7 +15,7 @@ import { createApp } from 'vue' const MENTION_START = /(?=[a-z0-9_\-@.'])\B/.source // Capturing groups like: @user-id, @"guest/abc16def", @"federated_user/user-id", @"user-id with space" const MENTION_SIMPLE = /(@[a-z0-9_\-@.']+)/.source -const MENTION_GUEST = /@"guest\/[a-f0-9]+"/.source +const MENTION_GUEST = /@"(?:guest|email){1}\/[a-f0-9]+"/.source const MENTION_PREFIXED = /@"(?:federated_)?(?:group|team|user){1}\/[a-z0-9_\-@.' /:]+"/.source const MENTION_WITH_SPACE = /@"[a-z0-9_\-@.' ]+"/.source const MENTION_COMPLEX = `(${MENTION_GUEST}|${MENTION_PREFIXED}|${MENTION_WITH_SPACE})` diff --git a/tests/unit/mixins/richEditor.spec.js b/tests/unit/mixins/richEditor.spec.js index a01fa8960a..a7249a12d8 100644 --- a/tests/unit/mixins/richEditor.spec.js +++ b/tests/unit/mixins/richEditor.spec.js @@ -77,6 +77,7 @@ describe('richEditor.js', () => { 'hello foo@bar - hello @@foobar', '@foobar no space - \n\n@foobar @foobar', 'hello @"guest/47e0a7cf"', + 'hello @"email/47e0a7cf"', 'hello @"group/group-id" @"federated_user/user-id"', 'hello @"federated_user/user-id@server.com:8080"', ] @@ -86,6 +87,7 @@ describe('richEditor.js', () => { 'hello foo@bar - hello @@foobar', '@foobar no space -

@foobar @foobar', 'hello @"guest/47e0a7cf"', + 'hello @"email/47e0a7cf"', 'hello @"group/group-id" @"federated_user/user-id"', 'hello @"federated_user/user-id@server.com:8080"', ]