index.ts 920 B

1234567891011121314151617181920212223242526
  1. import { markdown as markdownLanguage } from '@codemirror/lang-markdown'
  2. import { shortcuts } from './shortcuts'
  3. import { languages } from '../index'
  4. import { Extension } from '@codemirror/state'
  5. import { Strikethrough } from '@lezer/markdown'
  6. import { HighlightStyle, syntaxHighlighting } from '@codemirror/language'
  7. import { tags } from '@lezer/highlight'
  8. export const markdown = (): Extension => {
  9. return [
  10. markdownLanguage({
  11. codeLanguages: languages,
  12. extensions: [Strikethrough],
  13. }),
  14. shortcuts(),
  15. syntaxHighlighting(markdownHighlightStyle),
  16. ]
  17. }
  18. const markdownHighlightStyle = HighlightStyle.define([
  19. { tag: tags.link, textDecoration: 'underline' },
  20. { tag: tags.heading, textDecoration: 'underline', fontWeight: 'bold' },
  21. { tag: tags.emphasis, fontStyle: 'italic' },
  22. { tag: tags.strong, fontWeight: 'bold' },
  23. { tag: tags.strikethrough, textDecoration: 'line-through' },
  24. ])