comment.d.ts 1.6 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. export { Comment_ as default }
  25. }
  26. /**
  27. * It represents a class that handles
  28. * [CSS comments](https://developer.mozilla.org/en-US/docs/Web/CSS/Comments)
  29. *
  30. * ```js
  31. * Once (root, { Comment }) {
  32. * const note = new Comment({ text: 'Note: …' })
  33. * root.append(note)
  34. * }
  35. * ```
  36. *
  37. * Remember that CSS comments inside selectors, at-rule parameters,
  38. * or declaration values will be stored in the `raws` properties
  39. * explained above.
  40. */
  41. declare class Comment_ extends Node {
  42. parent: Container | undefined
  43. raws: Comment.CommentRaws
  44. type: 'comment'
  45. /**
  46. * The comment's text.
  47. */
  48. get text(): string
  49. set text(value: string)
  50. constructor(defaults?: Comment.CommentProps)
  51. assign(overrides: Comment.CommentProps | object): this
  52. clone(overrides?: Partial<Comment.CommentProps>): this
  53. cloneAfter(overrides?: Partial<Comment.CommentProps>): this
  54. cloneBefore(overrides?: Partial<Comment.CommentProps>): this
  55. }
  56. declare class Comment extends Comment_ {}
  57. export = Comment