Diffdown is a real-time collaborative Markdown editor/previewer built on the AT Protocol
diffdown.com
1import * as _codemirror_state from '@codemirror/state';
2import { Parser } from '@lezer/common';
3import { LRLanguage, LanguageSupport } from '@codemirror/language';
4import { CompletionContext, CompletionResult } from '@codemirror/autocomplete';
5
6/**
7Type used to specify tags to complete.
8*/
9interface TagSpec {
10 /**
11 Define tag-specific attributes. Property names are attribute
12 names, and property values can be null to indicate free-form
13 attributes, or a list of strings for suggested attribute values.
14 */
15 attrs?: Record<string, null | readonly string[]>;
16 /**
17 When set to false, don't complete global attributes on this tag.
18 */
19 globalAttrs?: boolean;
20 /**
21 Can be used to specify a list of child tags that are valid
22 inside this tag. The default is to allow any tag.
23 */
24 children?: readonly string[];
25}
26/**
27HTML tag completion. Opens and closes tags and attributes in a
28context-aware way.
29*/
30declare function htmlCompletionSource(context: CompletionContext): CompletionResult | null;
31/**
32Create a completion source for HTML extended with additional tags
33or attributes.
34*/
35declare function htmlCompletionSourceWith(config: {
36 /**
37 Define extra tag names to complete.
38 */
39 extraTags?: Record<string, TagSpec>;
40 /**
41 Add global attributes that are available on all tags.
42 */
43 extraGlobalAttributes?: Record<string, null | readonly string[]>;
44}): (context: CompletionContext) => CompletionResult | null;
45
46type NestedLang = {
47 tag: string;
48 attrs?: (attrs: {
49 [attr: string]: string;
50 }) => boolean;
51 parser: Parser;
52};
53type NestedAttr = {
54 name: string;
55 tagName?: string;
56 parser: Parser;
57};
58/**
59A language provider based on the [Lezer HTML
60parser](https://github.com/lezer-parser/html), extended with the
61JavaScript and CSS parsers to parse the content of `<script>` and
62`<style>` tags.
63*/
64declare const htmlLanguage: LRLanguage;
65/**
66Language support for HTML, including
67[`htmlCompletion`](https://codemirror.net/6/docs/ref/#lang-html.htmlCompletion) and JavaScript and
68CSS support extensions.
69*/
70declare function html(config?: {
71 /**
72 By default, the syntax tree will highlight mismatched closing
73 tags. Set this to `false` to turn that off (for example when you
74 expect to only be parsing a fragment of HTML text, not a full
75 document).
76 */
77 matchClosingTags?: boolean;
78 /**
79 By default, the parser does not allow arbitrary self-closing tags.
80 Set this to `true` to turn on support for `/>` self-closing tag
81 syntax.
82 */
83 selfClosingTags?: boolean;
84 /**
85 Determines whether [`autoCloseTags`](https://codemirror.net/6/docs/ref/#lang-html.autoCloseTags)
86 is included in the support extensions. Defaults to true.
87 */
88 autoCloseTags?: boolean;
89 /**
90 Add additional tags that can be completed.
91 */
92 extraTags?: Record<string, TagSpec>;
93 /**
94 Add additional completable attributes to all tags.
95 */
96 extraGlobalAttributes?: Record<string, null | readonly string[]>;
97 /**
98 Register additional languages to parse the content of specific
99 tags. If given, `attrs` should be a function that, given an
100 object representing the tag's attributes, returns `true` if this
101 language applies.
102 */
103 nestedLanguages?: NestedLang[];
104 /**
105 Register additional languages to parse attribute values with.
106 */
107 nestedAttributes?: NestedAttr[];
108}): LanguageSupport;
109/**
110Extension that will automatically insert close tags when a `>` or
111`/` is typed.
112*/
113declare const autoCloseTags: _codemirror_state.Extension;
114
115export { type TagSpec, autoCloseTags, html, htmlCompletionSource, htmlCompletionSourceWith, htmlLanguage };