index.d.cts 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import { NodeSpec, NodeType, Attrs } from 'prosemirror-model';
  2. import OrderedMap from 'orderedmap';
  3. import { Command } from 'prosemirror-state';
  4. /**
  5. An ordered list [node spec](https://prosemirror.net/docs/ref/#model.NodeSpec). Has a single
  6. attribute, `order`, which determines the number at which the list
  7. starts counting, and defaults to 1. Represented as an `<ol>`
  8. element.
  9. */
  10. declare const orderedList: NodeSpec;
  11. /**
  12. A bullet list node spec, represented in the DOM as `<ul>`.
  13. */
  14. declare const bulletList: NodeSpec;
  15. /**
  16. A list item (`<li>`) spec.
  17. */
  18. declare const listItem: NodeSpec;
  19. /**
  20. Convenience function for adding list-related node types to a map
  21. specifying the nodes for a schema. Adds
  22. [`orderedList`](https://prosemirror.net/docs/ref/#schema-list.orderedList) as `"ordered_list"`,
  23. [`bulletList`](https://prosemirror.net/docs/ref/#schema-list.bulletList) as `"bullet_list"`, and
  24. [`listItem`](https://prosemirror.net/docs/ref/#schema-list.listItem) as `"list_item"`.
  25. `itemContent` determines the content expression for the list items.
  26. If you want the commands defined in this module to apply to your
  27. list structure, it should have a shape like `"paragraph block*"` or
  28. `"paragraph (ordered_list | bullet_list)*"`. `listGroup` can be
  29. given to assign a group name to the list node types, for example
  30. `"block"`.
  31. */
  32. declare function addListNodes(nodes: OrderedMap<NodeSpec>, itemContent: string, listGroup?: string): OrderedMap<NodeSpec>;
  33. /**
  34. Returns a command function that wraps the selection in a list with
  35. the given type an attributes. If `dispatch` is null, only return a
  36. value to indicate whether this is possible, but don't actually
  37. perform the change.
  38. */
  39. declare function wrapInList(listType: NodeType, attrs?: Attrs | null): Command;
  40. /**
  41. Build a command that splits a non-empty textblock at the top level
  42. of a list item by also splitting that list item.
  43. */
  44. declare function splitListItem(itemType: NodeType, itemAttrs?: Attrs): Command;
  45. /**
  46. Create a command to lift the list item around the selection up into
  47. a wrapping list.
  48. */
  49. declare function liftListItem(itemType: NodeType): Command;
  50. /**
  51. Create a command to sink the list item around the selection down
  52. into an inner list.
  53. */
  54. declare function sinkListItem(itemType: NodeType): Command;
  55. export { addListNodes, bulletList, liftListItem, listItem, orderedList, sinkListItem, splitListItem, wrapInList };