1 | import type { Abbreviation } from '@emmetio/abbreviation';
|
2 | import type { CSSSnippet } from './stylesheet/snippets.js';
|
3 | export type SyntaxType = 'markup' | 'stylesheet';
|
4 | export type FieldOutput = (index: number, placeholder: string, offset: number, line: number, column: number) => string;
|
5 | export type TextOutput = (text: string, offset: number, line: number, column: number) => string;
|
6 | export type StringCase = '' | 'lower' | 'upper';
|
7 | export interface SnippetsMap {
|
8 | [name: string]: string;
|
9 | }
|
10 | export interface AbbreviationContext {
|
11 | name: string;
|
12 | attributes?: {
|
13 | [name: string]: string | null;
|
14 | };
|
15 | }
|
16 | /**
|
17 | * Raw config which contains per-syntax options. `markup` and `syntax` keys are
|
18 | * reserved for global settings for all markup and stylesheet syntaxes
|
19 | */
|
20 | export interface GlobalConfig {
|
21 | [syntax: string]: Partial<BaseConfig>;
|
22 | }
|
23 | export interface BaseConfig {
|
24 | type: SyntaxType;
|
25 | /** Options for abbreviation output */
|
26 | options: Partial<Options>;
|
27 | /** Substitutions for variable names */
|
28 | variables: SnippetsMap;
|
29 | /** Abbreviation name to snippets mapping */
|
30 | snippets: SnippetsMap;
|
31 | }
|
32 | interface ResolvedConfig extends BaseConfig {
|
33 | /** Host syntax */
|
34 | syntax: string;
|
35 | /**
|
36 | * Context of abbreviation. For markup abbreviation, it contains parent tag
|
37 | * name with attributes, for stylesheet abbreviation it contains property name
|
38 | * if abbreviation is expanded as value
|
39 | */
|
40 | context?: AbbreviationContext;
|
41 | /** Text to wrap with abbreviation */
|
42 | text?: string | string[];
|
43 | /** Max amount of repeated elements (fool proof) */
|
44 | maxRepeat?: number;
|
45 | /**
|
46 | * Object for storing internal cache data to be shared across Emmet methods
|
47 | * invocation. If provided, Emmet will store compute-intensive data in this
|
48 | * object and will re-use it during editor session.
|
49 | * Every time user settings are changed, you should empty cache by passing
|
50 | * new object.
|
51 | */
|
52 | cache?: Cache;
|
53 | /**
|
54 | * A callback for internal warnings or errors (for example, when parsing invalid abbreviation)
|
55 | */
|
56 | warn?: (message: string, err?: Error) => void;
|
57 | }
|
58 | export type Config = ResolvedConfig & {
|
59 | options: Options;
|
60 | };
|
61 | export type UserConfig = Partial<ResolvedConfig>;
|
62 | export interface Cache {
|
63 | stylesheetSnippets?: CSSSnippet[];
|
64 | markupSnippets?: {
|
65 | [name: string]: Abbreviation | null;
|
66 | };
|
67 | }
|
68 | export interface Options {
|
69 | /** A list of inline-level elements */
|
70 | inlineElements: string[];
|
71 | /** A string for one level indent */
|
72 | 'output.indent': string;
|
73 | /**
|
74 | * A string for base indent, e.g. context indentation which will be added
|
75 | * for every generated line
|
76 | */
|
77 | 'output.baseIndent': string;
|
78 | /** A string to use as a new line */
|
79 | 'output.newline': string;
|
80 | /** Tag case: lower, upper or '' (keep as-is) */
|
81 | 'output.tagCase': StringCase;
|
82 | /** Attribute name case: lower, upper or '' (keep as-is) */
|
83 | 'output.attributeCase': StringCase;
|
84 | /** Attribute value quotes: 'single' or 'double' */
|
85 | 'output.attributeQuotes': 'single' | 'double';
|
86 | /** Enable output formatting (indentation and line breaks) */
|
87 | 'output.format': boolean;
|
88 | /** When enabled, automatically adds inner line breaks for leaf (e.g. without children) nodes */
|
89 | 'output.formatLeafNode': boolean;
|
90 | /** A list of tag names that should not get inner indentation */
|
91 | 'output.formatSkip': string[];
|
92 | /** A list of tag names that should *always* get inner indentation. */
|
93 | 'output.formatForce': string[];
|
94 | /**
|
95 | * How many inline sibling elements should force line break for each tag.
|
96 | * Set to `0` to output all inline elements without formatting.
|
97 | * Set to `1` to output all inline elements with formatting (same as block-level).
|
98 | */
|
99 | 'output.inlineBreak': number;
|
100 | /**
|
101 | * Produce compact notation of boolean attributes: attributes which doesn’t have value.
|
102 | * With this option enabled, outputs `<div contenteditable>` instead of
|
103 | * `<div contenteditable="contenteditable">`
|
104 | */
|
105 | 'output.compactBoolean': boolean;
|
106 | /** A list of boolean attributes */
|
107 | 'output.booleanAttributes': string[];
|
108 | /** Reverses attribute merging directions when resolving snippets */
|
109 | 'output.reverseAttributes': boolean;
|
110 | /** Style of self-closing tags: html (`<br>`), xml (`<br/>`) or xhtml (`<br />`) */
|
111 | 'output.selfClosingStyle': 'html' | 'xml' | 'xhtml';
|
112 | /**
|
113 | * A function that takes field index and optional placeholder and returns
|
114 | * a string field (tabstop) for host editor. For example, a TextMate-style
|
115 | * field is `$index` or `${index:placeholder}`
|
116 | * @param index Field index
|
117 | * @param placeholder Field placeholder (default value), if any
|
118 | * @param offset Current character offset from the beginning of generated content
|
119 | * @param line Current line of generated output
|
120 | * @param column Current column in line
|
121 | */
|
122 | 'output.field': FieldOutput;
|
123 | /**
|
124 | * A function for processing text chunk passed to `OutputStream`.
|
125 | * May be used by editor for escaping characters, if necessary
|
126 | */
|
127 | 'output.text': TextOutput;
|
128 | /**
|
129 | * Automatically update value of <a> element's href attribute
|
130 | * if inserting URL or email
|
131 | */
|
132 | 'markup.href': boolean;
|
133 | /**
|
134 | * Attribute name mapping. Can be used to change attribute names for output.
|
135 | * For example, `class` -> `className` in JSX. If a key ends with `*`, this
|
136 | * value will be used for multi-attributes: currentry, it’s a `class` and `id`
|
137 | * since `multiple` marker is added for shorthand attributes only.
|
138 | * Example: `{ "class*": "styleName" }`
|
139 | */
|
140 | 'markup.attributes'?: Record<string, string>;
|
141 | /**
|
142 | * Prefixes for attribute values.
|
143 | * If specified, a value is treated as prefix for object notation and
|
144 | * automatically converts attribute value into expression if `jsx` is enabled.
|
145 | * Same as in `markup.attributes` option, a `*` can be used.
|
146 | */
|
147 | 'markup.valuePrefix'?: Record<string, string>;
|
148 | /**
|
149 | * Enable/disable element commenting: generate comments before open and/or
|
150 | * after close tag
|
151 | */
|
152 | 'comment.enabled': boolean;
|
153 | /**
|
154 | * Attributes that should trigger node commenting on specific node,
|
155 | * if commenting is enabled
|
156 | */
|
157 | 'comment.trigger': string[];
|
158 | /**
|
159 | * Template string for comment to be placed *before* opening tag
|
160 | */
|
161 | 'comment.before': string;
|
162 | /**
|
163 | * Template string for comment to be placed *after* closing tag.
|
164 | * Example: `\n<!-- /[#ID][.CLASS] -->`
|
165 | */
|
166 | 'comment.after': string;
|
167 | /** Enable/disable BEM addon */
|
168 | 'bem.enabled': boolean;
|
169 | /** A string for separating elements in output class */
|
170 | 'bem.element': string;
|
171 | /** A string for separating modifiers in output class */
|
172 | 'bem.modifier': string;
|
173 | /** Enable/disable JSX addon */
|
174 | 'jsx.enabled': boolean;
|
175 | /** List of globally available keywords for properties */
|
176 | 'stylesheet.keywords': string[];
|
177 | /**
|
178 | * List of unitless properties, e.g. properties where numeric values without
|
179 | * explicit unit will be outputted as is, without default value
|
180 | */
|
181 | 'stylesheet.unitless': string[];
|
182 | /** Use short hex notation where possible, e.g. `#000` instead of `#000000` */
|
183 | 'stylesheet.shortHex': boolean;
|
184 | /** A string between property name and value */
|
185 | 'stylesheet.between': string;
|
186 | /** A string after property value */
|
187 | 'stylesheet.after': string;
|
188 | /** A unit suffix to output by default after integer values, 'px' by default */
|
189 | 'stylesheet.intUnit': string;
|
190 | /** A unit suffix to output by default after float values, 'em' by default */
|
191 | 'stylesheet.floatUnit': string;
|
192 | /**
|
193 | * Aliases for custom units in abbreviation. For example, `r: 'rem'` will
|
194 | * output `10rem` for abbreviation `10r`
|
195 | */
|
196 | 'stylesheet.unitAliases': SnippetsMap;
|
197 | /** Output abbreviation as JSON object properties (for CSS-in-JS syntaxes) */
|
198 | 'stylesheet.json': boolean;
|
199 | /** Use double quotes for JSON values */
|
200 | 'stylesheet.jsonDoubleQuotes': boolean;
|
201 | /**
|
202 | * A float number between 0 and 1 to pick fuzzy-matched abbreviations.
|
203 | * Lower value will pick more abbreviations (and less accurate)
|
204 | */
|
205 | 'stylesheet.fuzzySearchMinScore': number;
|
206 | /**
|
207 | * Force strict abbreviation match. If Emmet is unable to match abbreviation
|
208 | * with existing snippets, it will convert it to CSS property (`false`)
|
209 | * or skip it (`true`). E.g. `foo-bar` will expand to `foo: bar` if this option
|
210 | * is disabled or empty string if enabled
|
211 | */
|
212 | 'stylesheet.strictMatch': boolean;
|
213 | }
|
214 | /**
|
215 | * Default syntaxes for abbreviation types
|
216 | */
|
217 | export declare const defaultSyntaxes: {
|
218 | [name in SyntaxType]: string;
|
219 | };
|
220 | /**
|
221 | * List of all known syntaxes
|
222 | */
|
223 | export declare const syntaxes: {
|
224 | markup: string[];
|
225 | stylesheet: string[];
|
226 | };
|
227 | export declare const defaultOptions: Options;
|
228 | export declare const defaultConfig: Config;
|
229 | /**
|
230 | * Default per-syntax config
|
231 | */
|
232 | export declare const syntaxConfig: GlobalConfig;
|
233 | /**
|
234 | * Parses raw snippets definitions with possibly multiple keys into a plan
|
235 | * snippet map
|
236 | */
|
237 | export declare function parseSnippets(snippets: SnippetsMap): SnippetsMap;
|
238 | export default function resolveConfig(config?: UserConfig, globals?: GlobalConfig): Config;
|
239 | export {};
|