mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-29 18:49:00 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			50 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
			
		
		
	
	
			50 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
| diff --git a/build/mention.js b/build/mention.js
 | |
| deleted file mode 100644
 | |
| index 6d433b2062ba52bcc6d70c911d38575e91b89d2c..0000000000000000000000000000000000000000
 | |
| diff --git a/dist/index.js b/dist/index.js
 | |
| index 9ba3f42b4093dce3174866f3321e03334d70e92e..62b0015a4bd255148496190c23ee48d6e9b1b5c2 100644
 | |
| --- a/dist/index.js
 | |
| +++ b/dist/index.js
 | |
| @@ -606,6 +606,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);
 | |
| +						}
 | |
| +					});
 | |
|                  }
 | |
|              }
 | |
|          }, {
 | |
| @@ -1069,12 +1079,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 "\"",
 | |
| @@ -1082,8 +1091,8 @@ const defaultCommitKeyCodes = [
 | |
|      // - 2: Mention input (taking the minimal length into consideration to trigger the UI),
 | |
|      //
 | |
|      // 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})$`;
 | |
| +    //                      (0:      opening sequence        )(1:   marker   )(2:                typed mention               )$
 | |
| +    const pattern = `(?:^|[= ${ openAfterCharacters }])([${ marker }])([${ mentionCharacters }]${ numberOfCharacters })$`;
 | |
|      return new RegExp(pattern, 'u');
 | |
|  }
 | |
|  /**
 | 
