mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 18:12:29 +08:00
48 lines
2.6 KiB
Diff
48 lines
2.6 KiB
Diff
diff --git a/build/mention.js b/build/mention.js
|
|
deleted file mode 100644
|
|
index 3ef262a2fb7cbb953b35cb7e07a999edce6dc72a..0000000000000000000000000000000000000000
|
|
diff --git a/dist/index.js b/dist/index.js
|
|
index bbe511c5550e1cac8612e998034382b4eea1f1b8..8394fd8bba89f8a7b82d62fe613be6f12703ff53 100644
|
|
--- a/dist/index.js
|
|
+++ b/dist/index.js
|
|
@@ -603,6 +603,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);
|
|
+ }
|
|
+ });
|
|
}
|
|
}
|
|
}, {
|
|
@@ -1067,12 +1077,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 "\"",
|
|
@@ -1081,7 +1090,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');
|
|
}
|
|
/**
|