Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit 73e1487

Browse files
authored
Merge pull request #1908 from TriliumNext/feature/codemirror6
Update to CodeMirror 6
2 parents ae83f0a + 3a984ff commit 73e1487

File tree

66 files changed

+2536
-730
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+2536
-730
lines changed

apps/client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
"@popperjs/core": "2.11.8",
2424
"@triliumnext/ckeditor5": "workspace:*",
2525
"@triliumnext/commons": "workspace:*",
26+
"@triliumnext/codemirror": "workspace:*",
2627
"bootstrap": "5.3.6",
2728
"dayjs": "1.11.13",
2829
"dayjs-plugin-utc": "0.1.2",
2930
"debounce": "2.2.0",
3031
"draggabilly": "3.0.0",
31-
"eslint-linter-browserify": "9.26.0",
3232
"force-graph": "1.49.5",
3333
"globals": "16.1.0",
3434
"i18next": "25.1.2",

apps/client/src/components/note_context.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import type { ViewScope } from "../services/link.js";
1111
import type FNote from "../entities/fnote.js";
1212
import type TypeWidget from "../widgets/type_widgets/type_widget.js";
1313
import type { CKTextEditor } from "@triliumnext/ckeditor5";
14+
import type CodeMirror from "@triliumnext/codemirror";
1415

1516
export interface SetNoteOpts {
1617
triggerSwitchEvent?: unknown;
@@ -312,7 +313,7 @@ class NoteContext extends Component implements EventListener<"entitiesReloaded">
312313

313314
async getCodeEditor() {
314315
return this.timeout(
315-
new Promise<CodeMirrorInstance>((resolve) =>
316+
new Promise<CodeMirror>((resolve) =>
316317
appContext.triggerCommand("executeWithCodeEditor", {
317318
resolve,
318319
ntxId: this.ntxId

apps/client/src/libraries/codemirror/eslint.js

Lines changed: 0 additions & 74 deletions
This file was deleted.

apps/client/src/services/glob.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import libraryLoader from "./library_loader.js";
55
import ws from "./ws.js";
66
import froca from "./froca.js";
77
import linkService from "./link.js";
8-
import { lint } from "./eslint.js";
98

109
function setupGlobs() {
1110
window.glob.isDesktop = utils.isDesktop;
@@ -19,7 +18,6 @@ function setupGlobs() {
1918
// required for ESLint plugin and CKEditor
2019
window.glob.getActiveContextNote = () => appContext.tabManager.getActiveContextNote();
2120
window.glob.requireLibrary = libraryLoader.requireLibrary;
22-
window.glob.linter = lint;
2321
window.glob.appContext = appContext; // for debugging
2422
window.glob.froca = froca;
2523
window.glob.treeCache = froca; // compatibility for CKEditor builds for a while

apps/client/src/services/library_loader.ts

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,6 @@ export interface Library {
77
css?: string[];
88
}
99

10-
const CODE_MIRROR: Library = {
11-
js: () => {
12-
const scriptsToLoad = [
13-
"node_modules/codemirror/lib/codemirror.js",
14-
"node_modules/codemirror/addon/display/placeholder.js",
15-
"node_modules/codemirror/addon/edit/matchbrackets.js",
16-
"node_modules/codemirror/addon/edit/matchtags.js",
17-
"node_modules/codemirror/addon/fold/xml-fold.js",
18-
"node_modules/codemirror/addon/lint/lint.js",
19-
"node_modules/codemirror/addon/mode/loadmode.js",
20-
"node_modules/codemirror/addon/mode/multiplex.js",
21-
"node_modules/codemirror/addon/mode/overlay.js",
22-
"node_modules/codemirror/addon/mode/simple.js",
23-
"node_modules/codemirror/addon/search/match-highlighter.js",
24-
"node_modules/codemirror/mode/meta.js",
25-
"node_modules/codemirror/keymap/vim.js",
26-
"libraries/codemirror/eslint.js"
27-
];
28-
29-
const mimeTypes = mimeTypesService.getMimeTypes();
30-
for (const mimeType of mimeTypes) {
31-
if (mimeType.enabled && mimeType.codeMirrorSource) {
32-
scriptsToLoad.push(mimeType.codeMirrorSource);
33-
}
34-
}
35-
36-
return scriptsToLoad;
37-
},
38-
css: ["node_modules/codemirror/lib/codemirror.css", "node_modules/codemirror/addon/lint/lint.css"]
39-
};
40-
4110
const KATEX: Library = {
4211
js: ["node_modules/katex/dist/katex.min.js", "node_modules/katex/dist/contrib/mhchem.min.js", "node_modules/katex/dist/contrib/auto-render.min.js"],
4312
css: ["node_modules/katex/dist/katex.min.css"]
@@ -152,7 +121,6 @@ export default {
152121
requireCss,
153122
requireLibrary,
154123
loadHighlightingTheme,
155-
CODE_MIRROR,
156124
KATEX,
157125
HIGHLIGHT_JS
158126
};

apps/client/src/services/mime_type_definitions.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export const MIME_TYPES_DICT: readonly MimeTypeDefinition[] = Object.freeze([
6868
{ title: "Forth", mime: "text/x-forth" },
6969
{ title: "Fortran", mime: "text/x-fortran", highlightJs: "fortran" },
7070
{ title: "Gas", mime: "text/x-gas" },
71+
{ title: "GDScript (Godot)", mime: "text/x-gdscript" },
7172
{ title: "Gherkin", mime: "text/x-feature", highlightJs: "gherkin" },
7273
{ title: "GitHub Flavored Markdown", mime: "text/x-gfm", highlightJs: "markdown" },
7374
{ title: "Go", mime: "text/x-go", highlightJs: "go", default: true },
@@ -106,6 +107,7 @@ export const MIME_TYPES_DICT: readonly MimeTypeDefinition[] = Object.freeze([
106107
{ title: "msgenny", mime: "text/x-msgenny" },
107108
{ title: "MUMPS", mime: "text/x-mumps" },
108109
{ title: "MySQL", mime: "text/x-mysql", highlightJs: "sql" },
110+
{ title: "Nix", mime: "text/x-nix", highlightJs: "nix" },
109111
{ title: "Nginx", mime: "text/x-nginx-conf", highlightJs: "nginx" },
110112
{ title: "NSIS", mime: "text/x-nsis", highlightJs: "nsis" },
111113
{ title: "NTriples", mime: "application/n-triples" },

apps/client/src/stylesheets/style.css

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -420,33 +420,24 @@ body.desktop #context-menu-container .dropdown-item > span {
420420
width: 100%;
421421
}
422422

423-
.CodeMirror {
423+
.cm-editor {
424424
height: 100%;
425-
background: inherit;
425+
outline: none !important;
426+
border-radius: 6px;
427+
overflow: hidden;
428+
margin: 4px;
426429
}
427430

428-
body .CodeMirror {
431+
body .cm-editor {
429432
font-size: var(--monospace-font-size);
430433
}
431434

432-
.CodeMirror-gutters {
435+
body .cm-editor .cm-gutters {
433436
background-color: inherit !important;
434437
border-right: none;
435438
}
436439

437-
.cm-matchhighlight {
438-
background-color: #eeeeee;
439-
}
440-
441-
.cm-matchhighlight.ck-find-result{
442-
background: var(--ck-color-highlight-background);
443-
}
444-
445-
.cm-matchhighlight.ck-find-result_selected {
446-
background-color: #ff9633;
447-
}
448-
449-
.CodeMirror pre.CodeMirror-placeholder {
440+
body .cm-editor .cm-placeholder {
450441
color: #999 !important;
451442
}
452443

@@ -457,11 +448,11 @@ body .CodeMirror {
457448
margin-bottom: 10px;
458449
}
459450

460-
#sql-console-query .CodeMirror {
451+
#sql-console-query .cm-editor {
461452
height: 150px;
462453
}
463454

464-
#sql-console-query .CodeMirror-scroll {
455+
#sql-console-query .cm-editor .cm-scroller {
465456
min-height: inherit !important;
466457
}
467458

@@ -524,7 +515,7 @@ button.btn-sm {
524515
padding: 0;
525516
}
526517

527-
pre:not(.CodeMirror-line):not(.hljs) {
518+
pre:not(.hljs) {
528519
color: var(--main-text-color) !important;
529520
white-space: pre-wrap;
530521
font-size: 100%;

apps/client/src/stylesheets/theme-dark.css

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,6 @@ body ::-webkit-calendar-picker-indicator {
8181
filter: invert(1);
8282
}
8383

84-
body .CodeMirror {
85-
filter: invert(90%) hue-rotate(180deg);
86-
}
87-
8884
.excalidraw.theme--dark {
8985
--theme-filter: invert(80%) hue-rotate(180deg) !important;
9086
}

apps/client/src/stylesheets/theme-next-dark.css

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,6 @@ body ::-webkit-calendar-picker-indicator {
244244
filter: invert(1);
245245
}
246246

247-
body .CodeMirror {
248-
filter: invert(90%) hue-rotate(180deg);
249-
}
250-
251247
.excalidraw.theme--dark {
252248
--theme-filter: invert(80%) hue-rotate(180deg) !important;
253249
}

apps/client/src/translations/cn/translation.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1616,7 +1616,7 @@
16161616
"auto-detect-language": "自动检测"
16171617
},
16181618
"highlighting": {
1619-
"title": "文本笔记的代码语法高亮",
1619+
"title": "",
16201620
"description": "控制文本笔记中代码块的语法高亮,代码笔记不会受到影响。",
16211621
"color-scheme": "颜色方案"
16221622
},

0 commit comments

Comments
 (0)