Compare commits

...

10 Commits

Author SHA1 Message Date
Elian Doran
60c789b6c7 fix(client): production affected by cache of index JS 2026-01-20 16:33:46 +02:00
Elian Doran
f83d95136d fix(codemirror): ctrl+enter generates newline 2026-01-20 16:11:40 +02:00
Elian Doran
f96ed0af26 Revert "fix(shortcuts): triggering in bubbling phase, not capturing"
This reverts commit 711828d6b4.
2026-01-20 15:16:51 +02:00
Elian Doran
1539664026 Revert "test(client): fix broken tests after change in shortcut behaviour"
This reverts commit e33950e000.
2026-01-20 15:16:32 +02:00
Elian Doran
8aff775d0e chore(deps): update pnpm to v10.28.1 (#8435) 2026-01-20 12:12:26 +02:00
Elian Doran
94248eafe9 chore(deps): update dependency vite-plugin-static-copy to v3.1.5 (#8434) 2026-01-20 12:12:06 +02:00
Elian Doran
02335bba3f chore(deps): update dependency turnish to v1.8.0 (#8437) 2026-01-20 12:11:38 +02:00
renovate[bot]
dad9578b83 chore(deps): update dependency turnish to v1.8.0 2026-01-20 01:16:12 +00:00
renovate[bot]
c043788b09 chore(deps): update pnpm to v10.28.1 2026-01-20 01:15:00 +00:00
renovate[bot]
e5bc416b46 chore(deps): update dependency vite-plugin-static-copy to v3.1.5 2026-01-20 01:14:50 +00:00
9 changed files with 47 additions and 37 deletions

View File

@@ -9,7 +9,7 @@
"keywords": [],
"author": "Elian Doran <contact@eliandoran.me>",
"license": "AGPL-3.0-only",
"packageManager": "pnpm@10.28.0",
"packageManager": "pnpm@10.28.1",
"devDependencies": {
"@redocly/cli": "2.14.5",
"archiver": "7.0.1",

View File

@@ -81,6 +81,6 @@
"happy-dom": "20.3.3",
"lightningcss": "1.30.2",
"script-loader": "0.7.2",
"vite-plugin-static-copy": "3.1.4"
"vite-plugin-static-copy": "3.1.5"
}
}

View File

@@ -1,6 +1,6 @@
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import shortcuts, { isIMEComposing,keyMatches, matchesShortcut } from "./shortcuts.js";
import shortcuts, { isIMEComposing, keyMatches, matchesShortcut } from "./shortcuts.js";
// Mock utils module
vi.mock("./utils.js", () => ({
@@ -249,7 +249,7 @@ describe("shortcuts", () => {
const handler = vi.fn();
shortcuts.bindGlobalShortcut("ctrl+a", handler, "test-namespace");
expect(mockElement.addEventListener).toHaveBeenCalledWith("keydown", expect.any(Function), true);
expect(mockElement.addEventListener).toHaveBeenCalledWith("keydown", expect.any(Function));
});
it("should not bind shortcuts when handler is null", () => {
@@ -280,7 +280,7 @@ describe("shortcuts", () => {
const handler = vi.fn();
shortcuts.bindElShortcut(mockJQueryEl, "ctrl+a", handler, "test-namespace");
expect(mockEl.addEventListener).toHaveBeenCalledWith("keydown", expect.any(Function), true);
expect(mockEl.addEventListener).toHaveBeenCalledWith("keydown", expect.any(Function));
});
it("should fall back to document when element is empty", () => {
@@ -290,7 +290,7 @@ describe("shortcuts", () => {
const handler = vi.fn();
shortcuts.bindElShortcut(emptyJQuery, "ctrl+a", handler, "test-namespace");
expect(mockElement.addEventListener).toHaveBeenCalledWith("keydown", expect.any(Function), true);
expect(mockElement.addEventListener).toHaveBeenCalledWith("keydown", expect.any(Function));
});
});
@@ -301,7 +301,7 @@ describe("shortcuts", () => {
shortcuts.removeGlobalShortcut("test-namespace");
expect(mockElement.removeEventListener).toHaveBeenCalledWith("keydown", expect.any(Function), true);
expect(mockElement.removeEventListener).toHaveBeenCalledWith("keydown", expect.any(Function));
});
});

View File

@@ -110,9 +110,8 @@ function bindElShortcut($el: JQuery<ElementType | Element>, keyboardShortcut: st
}
};
// Add the event listener in capture phase to intercept events before they reach
// child elements like CodeMirror
element.addEventListener('keydown', listener, true);
// Add the event listener
element.addEventListener('keydown', listener);
// Store the binding for later cleanup
const binding: ShortcutBinding = {
@@ -139,16 +138,15 @@ export function removeIndividualBinding(binding: ShortcutBinding) {
if (activeBindingsInNamespace) {
activeBindings.set(key, activeBindingsInNamespace.filter(aBinding => aBinding.handler === binding.handler));
}
// Remove listener with capture phase to match how it was added
binding.element.removeEventListener("keydown", binding.listener, true);
binding.element.removeEventListener("keydown", binding.listener);
}
function removeNamespaceBindings(namespace: string) {
const bindings = activeBindings.get(namespace);
if (bindings) {
// Remove all event listeners for this namespace
bindings.forEach(binding => {
// Remove listener with capture phase to match how it was added
binding.element.removeEventListener('keydown', binding.listener, true);
binding.element.removeEventListener('keydown', binding.listener);
});
activeBindings.delete(namespace);
}

View File

@@ -93,7 +93,15 @@ export default defineConfig(() => ({
print: join(__dirname, "src", "print.tsx")
},
output: {
entryFileNames: "src/[name].js",
entryFileNames: (chunk) => {
// We enforce a hash in the main index file to avoid caching issues, this only works because we have the HTML entry point.
if (chunk.name === "index") {
return "src/[name]-[hash].js";
}
// For EJS-rendered pages (e.g. login) we need to have a stable name.
return "src/[name].js";
},
chunkFileNames: "src/[name]-[hash].js",
assetFileNames: "src/[name]-[hash].[ext]",
manualChunks: {

View File

@@ -126,7 +126,7 @@
"swagger-jsdoc": "6.2.8",
"time2fa": "1.4.2",
"tmp": "0.2.5",
"turnish": "1.7.1",
"turnish": "1.8.0",
"unescape": "1.0.1",
"vite": "7.3.1",
"ws": "8.19.0",

View File

@@ -93,7 +93,7 @@
"url": "https://github.com/TriliumNext/Trilium/issues"
},
"homepage": "https://triliumnotes.org",
"packageManager": "pnpm@10.28.0",
"packageManager": "pnpm@10.28.1",
"pnpm": {
"patchedDependencies": {
"@ckeditor/ckeditor5-mention": "patches/@ckeditor__ckeditor5-mention.patch",

View File

@@ -1,5 +1,5 @@
import { defaultKeymap, history, historyKeymap } from "@codemirror/commands";
import { EditorView, highlightActiveLine, keymap, lineNumbers, placeholder, ViewPlugin, ViewUpdate, type EditorViewConfig } from "@codemirror/view";
import { EditorView, highlightActiveLine, keymap, lineNumbers, placeholder, ViewPlugin, ViewUpdate, type EditorViewConfig, KeyBinding } from "@codemirror/view";
import { defaultHighlightStyle, StreamLanguage, syntaxHighlighting, indentUnit, bracketMatching, foldGutter, codeFolding } from "@codemirror/language";
import { Compartment, EditorSelection, EditorState, type Extension } from "@codemirror/state";
import { highlightSelectionMatches } from "@codemirror/search";
@@ -12,6 +12,17 @@ import { createSearchHighlighter, SearchHighlighter, searchMatchHighlightTheme }
export { default as ColorThemes, type ThemeDefinition, getThemeById } from "./color_themes.js";
// Custom keymap to prevent Ctrl+Enter from inserting a newline
// This allows the parent application to handle the shortcut (e.g., for "Run Active Note")
const preventCtrlEnterKeymap: readonly KeyBinding[] = [
{
key: "Ctrl-Enter",
mac: "Cmd-Enter",
run: () => true, // Return true to mark event as handled, preventing default newline insertion
preventDefault: true
}
];
type ContentChangedListener = () => void;
export interface EditorConfig {
@@ -59,6 +70,7 @@ export default class CodeMirror extends EditorView {
lineNumbers(),
indentUnit.of(" ".repeat(4)),
keymap.of([
...preventCtrlEnterKeymap,
...defaultKeymap,
...historyKeymap,
...smartIndentWithTab

30
pnpm-lock.yaml generated
View File

@@ -354,8 +354,8 @@ importers:
specifier: 0.7.2
version: 0.7.2
vite-plugin-static-copy:
specifier: 3.1.4
version: 3.1.4(vite@7.3.1(@types/node@24.10.9)(jiti@2.6.1)(less@4.1.3)(lightningcss@1.30.2)(sass-embedded@1.91.0)(sass@1.91.0)(terser@5.44.0)(tsx@4.21.0)(yaml@2.8.1))
specifier: 3.1.5
version: 3.1.5(vite@7.3.1(@types/node@24.10.9)(jiti@2.6.1)(less@4.1.3)(lightningcss@1.30.2)(sass-embedded@1.91.0)(sass@1.91.0)(terser@5.44.0)(tsx@4.21.0)(yaml@2.8.1))
apps/db-compare:
dependencies:
@@ -793,8 +793,8 @@ importers:
specifier: 0.2.5
version: 0.2.5
turnish:
specifier: 1.7.1
version: 1.7.1
specifier: 1.8.0
version: 1.8.0
unescape:
specifier: 1.0.1
version: 1.0.1
@@ -10962,10 +10962,6 @@ packages:
resolution: {integrity: sha512-/bjOqmgETBYB5BoEeGVea8dmvHb2m9GLy1E9W43yeyfP6QQCZGFNa+XRceJEuDB6zqr+gKpIAmlLebMpykw/MQ==}
engines: {node: '>=10'}
p-map@7.0.3:
resolution: {integrity: sha512-VkndIv2fIB99swvQoA65bm+fsmt6UNdGeIB0oxBs+WhAhdh08QA04JXpI7rbB9r08/nkbysKoya9rtDERYOYMA==}
engines: {node: '>=18'}
p-map@7.0.4:
resolution: {integrity: sha512-tkAQEw8ysMzmkhgw8k+1U/iPhWNhykKnSk4Rd5zLoPJCuJaGRPo6YposrZgaxHKzDHdDWWZvE/Sk7hsL2X/CpQ==}
engines: {node: '>=18'}
@@ -13483,8 +13479,8 @@ packages:
turndown@7.2.2:
resolution: {integrity: sha512-1F7db8BiExOKxjSMU2b7if62D/XOyQyZbPKq/nUwopfgnHlqXHqQ0lvfUTeUIr1lZJzOPFn43dODyMSIfvWRKQ==}
turnish@1.7.1:
resolution: {integrity: sha512-NgyY7pIDABjKyg2isRgZyFPav6tOyvmqpTx3HROsKrOaE3JccP4C1P2IhAtkAZ8DkQb/O1R7HOFAkxY8uaJmcQ==}
turnish@1.8.0:
resolution: {integrity: sha512-r1K94mbU5FHwvHKsPrTejuxoQTyKrddeWNzxS53Dnu+33DJLZJzfAHmo7GhdxBvhrHYCfv/diYvpq2VCGSGa+w==}
type-check@0.4.0:
resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==}
@@ -13864,8 +13860,8 @@ packages:
vite:
optional: true
vite-plugin-static-copy@3.1.4:
resolution: {integrity: sha512-iCmr4GSw4eSnaB+G8zc2f4dxSuDjbkjwpuBLLGvQYR9IW7rnDzftnUjOH5p4RYR+d4GsiBqXRvzuFhs5bnzVyw==}
vite-plugin-static-copy@3.1.5:
resolution: {integrity: sha512-9pbZn9Vb+uUNg/Tr/f2MXmGvfSfLeWjscS4zTA3v+sWqKN+AjJ/ipTFwaqdopJkNkxG5DfgYrZXD80ljbNDxbg==}
engines: {node: ^18.0.0 || >=20.0.0}
peerDependencies:
vite: ^5.0.0 || ^6.0.0 || ^7.0.0
@@ -15311,8 +15307,6 @@ snapshots:
'@ckeditor/ckeditor5-utils': 47.4.0
'@ckeditor/ckeditor5-watchdog': 47.4.0
es-toolkit: 1.39.5
transitivePeerDependencies:
- supports-color
'@ckeditor/ckeditor5-dev-build-tools@54.3.0(@swc/helpers@0.5.17)(tslib@2.8.1)(typescript@5.9.3)':
dependencies:
@@ -27150,8 +27144,6 @@ snapshots:
dependencies:
aggregate-error: 3.1.0
p-map@7.0.3: {}
p-map@7.0.4: {}
p-queue@6.6.2:
@@ -30130,7 +30122,7 @@ snapshots:
dependencies:
'@mixmark-io/domino': 2.2.0
turnish@1.7.1:
turnish@1.8.0:
dependencies:
'@adobe/css-tools': 4.4.4
'@mixmark-io/domino': 2.2.0
@@ -30503,10 +30495,10 @@ snapshots:
- rollup
- supports-color
vite-plugin-static-copy@3.1.4(vite@7.3.1(@types/node@24.10.9)(jiti@2.6.1)(less@4.1.3)(lightningcss@1.30.2)(sass-embedded@1.91.0)(sass@1.91.0)(terser@5.44.0)(tsx@4.21.0)(yaml@2.8.1)):
vite-plugin-static-copy@3.1.5(vite@7.3.1(@types/node@24.10.9)(jiti@2.6.1)(less@4.1.3)(lightningcss@1.30.2)(sass-embedded@1.91.0)(sass@1.91.0)(terser@5.44.0)(tsx@4.21.0)(yaml@2.8.1)):
dependencies:
chokidar: 3.6.0
p-map: 7.0.3
p-map: 7.0.4
picocolors: 1.1.1
tinyglobby: 0.2.15
vite: 7.3.1(@types/node@24.10.9)(jiti@2.6.1)(less@4.1.3)(lightningcss@1.30.2)(sass-embedded@1.91.0)(sass@1.91.0)(terser@5.44.0)(tsx@4.21.0)(yaml@2.8.1)