comment.d.ts 1.7 KB

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