feat(ui): reconcile backup UI changes with current routing and interaction features

This commit is contained in:
Dotta
2026-03-02 16:44:03 -06:00
parent 83be94361c
commit 8ee063c4e5
69 changed files with 1591 additions and 666 deletions

View File

@@ -10,9 +10,11 @@ import {
type DragEvent,
} from "react";
import {
CodeMirrorEditor,
MDXEditor,
codeBlockPlugin,
codeMirrorPlugin,
type CodeBlockEditorDescriptor,
type MDXEditorMethods,
headingsPlugin,
imagePlugin,
@@ -90,6 +92,14 @@ const CODE_BLOCK_LANGUAGES: Record<string, string> = {
yml: "YAML",
};
const FALLBACK_CODE_BLOCK_DESCRIPTOR: CodeBlockEditorDescriptor = {
// Keep this lower than codeMirrorPlugin's descriptor priority so known languages
// still use the standard matching path; this catches malformed/unknown fences.
priority: 0,
match: () => true,
Editor: CodeMirrorEditor,
};
function detectMention(container: HTMLElement): MentionState | null {
const sel = window.getSelection();
if (!sel || sel.rangeCount === 0 || !sel.isCollapsed) return null;
@@ -247,7 +257,10 @@ export const MarkdownEditor = forwardRef<MarkdownEditorRef, MarkdownEditorProps>
linkPlugin(),
linkDialogPlugin(),
thematicBreakPlugin(),
codeBlockPlugin(),
codeBlockPlugin({
defaultCodeBlockLanguage: "txt",
codeBlockEditorDescriptors: [FALLBACK_CODE_BLOCK_DESCRIPTOR],
}),
codeMirrorPlugin({ codeBlockLanguages: CODE_BLOCK_LANGUAGES }),
markdownShortcutPlugin(),
];