feat(ui): reconcile backup UI changes with current routing and interaction features
This commit is contained in:
@@ -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(),
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user