Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(markdown): slash commands can be triggered from code blocks
Elian Doranae0d77a646ce
diff --git a/apps/client/src/widgets/type_widgets/code/Markdown.tsx b/apps/client/src/widgets/type_widgets/code/Markdown.tsxindex f85c69653e..6b43c1e323 100644--- a/apps/client/src/widgets/type_widgets/code/Markdown.tsx+++ b/apps/client/src/widgets/type_widgets/code/Markdown.tsx@@ -456,6 +456,11 @@ function useSlashCommands(parentComponent: TypeWidgetProps["parentComponent"], econst match = ctx.matchBefore(/(?:^|(?<=\s))\/\w*/);if (!match) return null;+ // Suppress inside fenced code blocks (``` ... ```).+ const textBefore = ctx.state.sliceDoc(0, match.from);+ const fenceCount = (textBefore.match(/^(`{3,}|~{3,})/gm) ?? []).length;+ if (fenceCount % 2 !== 0) return null;+return {from: match.from,options: [