Skip to content

Build your personal knowledge base with Trilium Notes

chore(ckeditor): edit patches & add one for code blocks

Elian Doran5db6043017b6
diff --git a/package.json b/package.json
index 1f9c7039f7..4be2e80350 100644
--- a/package.json
+++ b/package.json
@@ -24,8 +24,8 @@
},
"private": true,
"devDependencies": {
- "@eslint/js": "^9.8.0",
"@electron/rebuild": "4.0.1",
+ "@eslint/js": "^9.8.0",
"@nx/devkit": "21.0.0",
"@nx/esbuild": "21.0.0",
"@nx/eslint": "21.0.0",
@@ -91,7 +91,8 @@
"packageManager": "[email protected]+sha512.d615db246fe70f25dcfea6d8d73dee782ce23e2245e3c4f6f888249fb568149318637dca73c2c5c8ef2a4ca0d5657fb9567188bfab47f566d1ee6ce987815c39",
"pnpm": {
"patchedDependencies": {
- "@ckeditor/ckeditor5-mention": "patches/@ckeditor__ckeditor5-mention.patch"
+ "@ckeditor/ckeditor5-mention": "patches/@ckeditor__ckeditor5-mention.patch",
+ "@ckeditor/ckeditor5-code-block": "patches/@ckeditor__ckeditor5-code-block.patch"
}
}
}
diff --git a/patches/@ckeditor__ckeditor5-code-block.patch b/patches/@ckeditor__ckeditor5-code-block.patch
new file mode 100644
index 0000000000..8a47798900
--- /dev/null
+++ b/patches/@ckeditor__ckeditor5-code-block.patch
@@ -0,0 +1,37 @@
+diff --git a/dist/index.css b/dist/index.css
+index 8276289d55abd0f70d399e33c5f6c2d006745000..c70f12f1644dcebea6730b9b201a6933fa28969b 100644
+--- a/dist/index.css
++++ b/dist/index.css
+@@ -9,8 +9,6 @@
+
+ .ck-content pre {
+ padding: 1em;
+- color: hsl(0, 0%, 20.8%);
+- background: hsla(0, 0%, 78%, 0.3);
+ border: 1px solid hsl(0, 0%, 77%);
+ border-radius: 2px;
+
+@@ -28,6 +26,11 @@
+ min-width: 200px;
+ }
+
++.ck-content pre:not(.hljs) {
++ color: hsl(0, 0%, 20.8%);
++ background: hsla(0, 0%, 78%, 0.3);
++}
++
+ .ck-content pre code {
+ background: unset;
+ padding: 0;
+diff --git a/dist/index.js b/dist/index.js
+index f0f8aec2323e8cdb34fa0bb4f48c2b433abcb804..b9600d356df2bf1922d51c6cebd1f74ee3ed9155 100644
+--- a/dist/index.js
++++ b/dist/index.js
+@@ -656,6 +656,7 @@ function getLastOutdentableSequenceRange(model, position, sequence) {
+ // Attributes added only in the editing view.
+ if (useLabels) {
+ preAttributes['data-language'] = languagesToLabels[codeBlockLanguage];
++ preAttributes.class = "hljs";
+ preAttributes.spellcheck = 'false';
+ }
+ const codeAttributes = languagesToClasses[codeBlockLanguage] ? {
diff --git a/patches/@ckeditor__ckeditor5-mention.patch b/patches/@ckeditor__ckeditor5-mention.patch
index 0c1bee53f9..14ab0b9ba9 100644
--- a/patches/@ckeditor__ckeditor5-mention.patch
+++ b/patches/@ckeditor__ckeditor5-mention.patch
@@ -1,11 +1,11 @@
diff --git a/build/mention.js b/build/mention.js
deleted file mode 100644
-index 6d433b2062ba52bcc6d70c911d38575e91b89d2c..0000000000000000000000000000000000000000
+index 3ef262a2fb7cbb953b35cb7e07a999edce6dc72a..0000000000000000000000000000000000000000
diff --git a/dist/index.js b/dist/index.js
-index 9ba3f42b4093dce3174866f3321e03334d70e92e..62b0015a4bd255148496190c23ee48d6e9b1b5c2 100644
+index bbe511c5550e1cac8612e998034382b4eea1f1b8..8394fd8bba89f8a7b82d62fe613be6f12703ff53 100644
--- a/dist/index.js
+++ b/dist/index.js
-@@ -606,6 +606,16 @@ const defaultCommitKeyCodes = [
+@@ -603,6 +603,16 @@ const defaultCommitKeyCodes = [
}
if (data.keyCode == keyCodes.esc) {
this._hideUIAndRemoveMarker();
@@ -22,7 +22,7 @@ index 9ba3f42b4093dce3174866f3321e03334d70e92e..62b0015a4bd255148496190c23ee48d6
}
}
}, {
-@@ -1069,12 +1079,11 @@ const defaultCommitKeyCodes = [
+@@ -1067,12 +1077,11 @@ const defaultCommitKeyCodes = [
*/ function createRegExp(marker, minimumCharacters) {
const numberOfCharacters = minimumCharacters == 0 ? '*' : `{${minimumCharacters},}`;
const openAfterCharacters = env.features.isRegExpUnicodePropertySupported ? '\\p{Ps}\\p{Pi}"\'' : '\\(\\[{"\'';
@@ -36,13 +36,11 @@ index 9ba3f42b4093dce3174866f3321e03334d70e92e..62b0015a4bd255148496190c23ee48d6
// 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),
+@@ -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})$`;
-+ // (0: opening sequence )(1: marker )(2: typed mention )$
+ // (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');
}