UNPKG

1.73 kBTypeScriptView Raw
1import Container from './container.js'
2import Node, { NodeProps } from './node.js'
3
4declare namespace Comment {
5 export interface CommentRaws extends Record<string, unknown> {
6 /**
7 * The space symbols before the node.
8 */
9 before?: string
10
11 /**
12 * The space symbols between `/*` and the comment’s text.
13 */
14 left?: string
15
16 /**
17 * The space symbols between the comment’s text.
18 */
19 right?: string
20 }
21
22 export interface CommentProps extends NodeProps {
23 /** Information used to generate byte-to-byte equal node string as it was in the origin input. */
24 raws?: CommentRaws
25 /** Content of the comment. */
26 text: string
27 }
28
29 // eslint-disable-next-line @typescript-eslint/no-use-before-define
30 export { Comment_ as default }
31}
32
33/**
34 * It represents a class that handles
35 * [CSS comments](https://developer.mozilla.org/en-US/docs/Web/CSS/Comments)
36 *
37 * ```js
38 * Once (root, { Comment }) {
39 * const note = new Comment({ text: 'Note: …' })
40 * root.append(note)
41 * }
42 * ```
43 *
44 * Remember that CSS comments inside selectors, at-rule parameters,
45 * or declaration values will be stored in the `raws` properties
46 * explained above.
47 */
48declare class Comment_ extends Node {
49 parent: Container | undefined
50 raws: Comment.CommentRaws
51 /**
52 * The comment's text.
53 */
54 text: string
55
56 type: 'comment'
57
58 constructor(defaults?: Comment.CommentProps)
59 assign(overrides: Comment.CommentProps | object): this
60 clone(overrides?: Partial<Comment.CommentProps>): Comment
61 cloneAfter(overrides?: Partial<Comment.CommentProps>): Comment
62 cloneBefore(overrides?: Partial<Comment.CommentProps>): Comment
63}
64
65declare class Comment extends Comment_ {}
66
67export = Comment