first commit

This commit is contained in:
2025-04-24 13:11:28 +08:00
commit ff9c54d5e4
5960 changed files with 834111 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
import { markdown as markdownLanguage } from '@codemirror/lang-markdown'
import { shortcuts } from './shortcuts'
import { languages } from '../index'
import { Strikethrough } from '@lezer/markdown'
import {
HighlightStyle,
LanguageSupport,
syntaxHighlighting,
} from '@codemirror/language'
import { tags } from '@lezer/highlight'
export const markdown = () => {
const { language, support } = markdownLanguage({
codeLanguages: languages,
extensions: [Strikethrough],
})
return new LanguageSupport(language, [
support,
shortcuts(),
syntaxHighlighting(markdownHighlightStyle),
])
}
const markdownHighlightStyle = HighlightStyle.define([
{ tag: tags.link, textDecoration: 'underline' },
{ tag: tags.heading, textDecoration: 'underline', fontWeight: 'bold' },
{ tag: tags.emphasis, fontStyle: 'italic' },
{ tag: tags.strong, fontWeight: 'bold' },
{ tag: tags.strikethrough, textDecoration: 'line-through' },
])

View File

@@ -0,0 +1,22 @@
import { Prec } from '@codemirror/state'
import { keymap } from '@codemirror/view'
import { wrapRanges } from '../../commands/ranges'
export const shortcuts = () => {
return Prec.high(
keymap.of([
{
key: 'Ctrl-b',
mac: 'Mod-b',
preventDefault: true,
run: wrapRanges('**', '**'),
},
{
key: 'Ctrl-i',
mac: 'Mod-i',
preventDefault: true,
run: wrapRanges('_', '_'),
},
])
)
}