Skip to content

Build your personal knowledge base with Trilium Notes

chore(ckeditor): update patch

Elian Doran2aa14b53e72b
diff --git a/patches/@ckeditor__ckeditor5-mention.patch b/patches/@ckeditor__ckeditor5-mention.patch
index 9281de4890..0c1bee53f9 100644
--- a/patches/@ckeditor__ckeditor5-mention.patch
+++ b/patches/@ckeditor__ckeditor5-mention.patch
@@ -1,8 +1,34 @@
-diff --git a/src/mentionui.js b/src/mentionui.js
-index 96df6deedcebf00ad089835301383022337ace1c..a45f6ddc9c195a40faf6a034266402e2a7993ccd 100644
---- a/src/mentionui.js
-+++ b/src/mentionui.js
-@@ -529,7 +529,6 @@ export function createRegExp(marker, minimumCharacters) {
+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.
@@ -10,11 +36,13 @@ index 96df6deedcebf00ad089835301383022337ace1c..a45f6ddc9c195a40faf6a034266402e2
// The pattern consists of 3 groups:
//
// - 0 (non-capturing): Opening sequence - start of the line, space or an opening punctuation character like "(" or "\"",
-@@ -538,7 +537,7 @@ export function createRegExp(marker, minimumCharacters) {
+@@ -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 )$
+- // (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');
}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 324d5e7ed7..70ad11e95d 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -6,7 +6,7 @@ settings:
patchedDependencies:
'@ckeditor/ckeditor5-mention':
- hash: ea634450951529f434461216c50e9197d59e5cf9992c25ef1d38c602268d1313
+ hash: 85d0644b0882025fa014b64b45244e9f7503ef5d8b57f7868eb2d4b5c139ee84
path: patches/@ckeditor__ckeditor5-mention.patch
importers:
@@ -15396,7 +15396,7 @@ snapshots:
'@ckeditor/ckeditor5-widget': 43.2.0
ckeditor5: 43.2.0
- '@ckeditor/[email protected](patch_hash=ea634450951529f434461216c50e9197d59e5cf9992c25ef1d38c602268d1313)':
+ '@ckeditor/[email protected](patch_hash=85d0644b0882025fa014b64b45244e9f7503ef5d8b57f7868eb2d4b5c139ee84)':
dependencies:
'@ckeditor/ckeditor5-core': 43.2.0
'@ckeditor/ckeditor5-typing': 43.2.0
@@ -20849,7 +20849,7 @@ snapshots:
'@ckeditor/ckeditor5-list': 43.2.0
'@ckeditor/ckeditor5-markdown-gfm': 43.2.0
'@ckeditor/ckeditor5-media-embed': 43.2.0
- '@ckeditor/ckeditor5-mention': 43.2.0(patch_hash=ea634450951529f434461216c50e9197d59e5cf9992c25ef1d38c602268d1313)
+ '@ckeditor/ckeditor5-mention': 43.2.0(patch_hash=85d0644b0882025fa014b64b45244e9f7503ef5d8b57f7868eb2d4b5c139ee84)
'@ckeditor/ckeditor5-minimap': 43.2.0
'@ckeditor/ckeditor5-page-break': 43.2.0
'@ckeditor/ckeditor5-paragraph': 43.2.0