first commit
This commit is contained in:
@@ -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' },
|
||||
])
|
||||
@@ -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('_', '_'),
|
||||
},
|
||||
])
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user