Diffdown is a real-time collaborative Markdown editor/previewer built on the AT Protocol diffdown.com
1import * as _codemirror_state from '@codemirror/state'; 2import { StateCommand } from '@codemirror/state'; 3import { KeyBinding } from '@codemirror/view'; 4import { Language, LanguageSupport, LanguageDescription } from '@codemirror/language'; 5import { MarkdownExtension } from '@lezer/markdown'; 6 7/** 8Language support for strict CommonMark. 9*/ 10declare const commonmarkLanguage: Language; 11/** 12Language support for [GFM](https://github.github.com/gfm/) plus 13subscript, superscript, and emoji syntax. 14*/ 15declare const markdownLanguage: Language; 16 17/** 18Returns a command like 19[`insertNewlineContinueMarkup`](https://codemirror.net/6/docs/ref/#lang-markdown.insertNewlineContinueMarkup), 20allowing further configuration. 21*/ 22declare const insertNewlineContinueMarkupCommand: (config?: { 23 /** 24 By default, when pressing enter in a blank second item in a 25 tight (no blank lines between items) list, the command will 26 insert a blank line above that item, starting a non-tight list. 27 Set this to false to disable this behavior. 28 */ 29 nonTightLists?: boolean; 30}) => StateCommand; 31/** 32This command, when invoked in Markdown context with cursor 33selection(s), will create a new line with the markup for 34blockquotes and lists that were active on the old line. If the 35cursor was directly after the end of the markup for the old line, 36trailing whitespace and list markers are removed from that line. 37 38The command does nothing in non-Markdown context, so it should 39not be used as the only binding for Enter (even in a Markdown 40document, HTML and code regions might use a different language). 41*/ 42declare const insertNewlineContinueMarkup: StateCommand; 43/** 44This command will, when invoked in a Markdown context with the 45cursor directly after list or blockquote markup, delete one level 46of markup. When the markup is for a list, it will be replaced by 47spaces on the first invocation (a further invocation will delete 48the spaces), to make it easy to continue a list. 49 50When not after Markdown block markup, this command will return 51false, so it is intended to be bound alongside other deletion 52commands, with a higher precedence than the more generic commands. 53*/ 54declare const deleteMarkupBackward: StateCommand; 55 56/** 57A small keymap with Markdown-specific bindings. Binds Enter to 58[`insertNewlineContinueMarkup`](https://codemirror.net/6/docs/ref/#lang-markdown.insertNewlineContinueMarkup) 59and Backspace to 60[`deleteMarkupBackward`](https://codemirror.net/6/docs/ref/#lang-markdown.deleteMarkupBackward). 61*/ 62declare const markdownKeymap: readonly KeyBinding[]; 63/** 64Markdown language support. 65*/ 66declare function markdown(config?: { 67 /** 68 When given, this language will be used by default to parse code 69 blocks. 70 */ 71 defaultCodeLanguage?: Language | LanguageSupport; 72 /** 73 A source of language support for highlighting fenced code 74 blocks. When it is an array, the parser will use 75 [`LanguageDescription.matchLanguageName`](https://codemirror.net/6/docs/ref/#language.LanguageDescription^matchLanguageName) 76 with the fenced code info to find a matching language. When it 77 is a function, will be called with the info string and may 78 return a language or `LanguageDescription` object. 79 */ 80 codeLanguages?: readonly LanguageDescription[] | ((info: string) => Language | LanguageDescription | null); 81 /** 82 Set this to false to disable installation of the Markdown 83 [keymap](https://codemirror.net/6/docs/ref/#lang-markdown.markdownKeymap). 84 */ 85 addKeymap?: boolean; 86 /** 87 Markdown parser 88 [extensions](https://github.com/lezer-parser/markdown#user-content-markdownextension) 89 to add to the parser. 90 */ 91 extensions?: MarkdownExtension; 92 /** 93 The base language to use. Defaults to 94 [`commonmarkLanguage`](https://codemirror.net/6/docs/ref/#lang-markdown.commonmarkLanguage). 95 */ 96 base?: Language; 97 /** 98 By default, the extension installs an autocompletion source that 99 completes HTML tags when a `<` is typed. Set this to false to 100 disable this. 101 */ 102 completeHTMLTags?: boolean; 103 /** 104 The returned language contains 105 [`pasteURLAsLink`](https://codemirror.net/6/docs/ref/#lang-markdown.pasteURLAsLink) as a support 106 extension unless you set this to false. 107 */ 108 pasteURLAsLink?: boolean; 109 /** 110 By default, HTML tags in the document are handled by the [HTML 111 language](https://github.com/codemirror/lang-html) package with 112 tag matching turned off. You can pass in an alternative language 113 configuration here if you want. 114 */ 115 htmlTagLanguage?: LanguageSupport; 116}): LanguageSupport; 117/** 118An extension that intercepts pastes when the pasted content looks 119like a URL and the selection is non-empty and selects regular 120text, making the selection a link with the pasted URL as target. 121*/ 122declare const pasteURLAsLink: _codemirror_state.Extension; 123 124export { commonmarkLanguage, deleteMarkupBackward, insertNewlineContinueMarkup, insertNewlineContinueMarkupCommand, markdown, markdownKeymap, markdownLanguage, pasteURLAsLink };