diff --git a/dist/index.js b/dist/index.js
index 5c1b7d98d6a47f56a00440a6753368676bc26a7a..46cf87ae341bd2405fb756ba827c61b5b062f6b6 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -609,6 +609,16 @@ const defaultCommitKeyCodes = [
                 }
                 if (data.keyCode == keyCodes.esc) {
                     this._hideUIAndRemoveMarker();
+
+                    editor.model.change(writer => {
+						// insert a zero-width space as a special marker that we don't want a mention active anymore
+						// see e.g. https://github.com/zadam/trilium/issues/4692
+						const insertPosition = editor.model.document.selection.getLastPosition();
+
+						if (insertPosition !== null) {
+							writer.insertText('\u2002', insertPosition);
+						}
+					});
                 }
             }
         }, {
@@ -1075,12 +1085,11 @@ const defaultCommitKeyCodes = [
  */ function createRegExp(marker, minimumCharacters) {
     const numberOfCharacters = minimumCharacters == 0 ? '*' : `{${minimumCharacters},}`;
     const openAfterCharacters = env.features.isRegExpUnicodePropertySupported ? '\\p{Ps}\\p{Pi}"\'' : '\\(\\[{"\'';
-    const mentionCharacters = '.';
+    const mentionCharacters = '^=\u2002';
     // I wanted to make an util out of it, but since this regexp uses "u" flag, it became difficult.
     // When "u" flag is used, the regexp has "strict" escaping rules, i.e. if you try to escape a character that does not need
     // to be escaped, RegExp() will throw. It made it difficult to write a generic util, because different characters are
     // allowed in different context. For example, escaping "-" sometimes was correct, but sometimes it threw an error.
-    marker = marker.replace(/[.*+?^${}()\-|[\]\\]/g, '\\$&');
     // The pattern consists of 3 groups:
     //
     // - 0 (non-capturing): Opening sequence - start of the line, space or an opening punctuation character like "(" or "\"",
@@ -1089,7 +1098,7 @@ const defaultCommitKeyCodes = [
     //
     // The pattern matches up to the caret (end of string switch - $).
     //               (0:      opening sequence       )(1: marker  )(2:                typed mention              )$
-    const pattern = `(?:^|[ ${openAfterCharacters}])(${marker})(${mentionCharacters}${numberOfCharacters})$`;
+    const pattern = `(?:^|[= ${ openAfterCharacters }])([${ marker }])([${ mentionCharacters }]${ numberOfCharacters })$`;
     return new RegExp(pattern, 'u');
 }
 /**
