1 | // Type definitions for prosemirror-schema-list 1.0
|
2 | // Project: https://github.com/ProseMirror/prosemirror-schema-list
|
3 | // Definitions by: Bradley Ayers <https://github.com/bradleyayers>
|
4 | // David Hahn <https://github.com/davidka>
|
5 | // Tim Baumann <https://github.com/timjb>
|
6 | // Patrick Simmelbauer <https://github.com/patsimm>
|
7 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
8 | // TypeScript Version: 2.3
|
9 |
|
10 | import OrderedMap = require('orderedmap');
|
11 | import { NodeSpec, NodeType, Schema } from 'prosemirror-model';
|
12 | import { EditorState, Transaction } from 'prosemirror-state';
|
13 |
|
14 | /**
|
15 | * An ordered list [node spec](#model.NodeSpec). Has a single
|
16 | * attribute, `order`, which determines the number at which the list
|
17 | * starts counting, and defaults to 1. Represented as an `<ol>`
|
18 | * element.
|
19 | */
|
20 | export let orderedList: NodeSpec;
|
21 | /**
|
22 | * A bullet list node spec, represented in the DOM as `<ul>`.
|
23 | */
|
24 | export let bulletList: NodeSpec;
|
25 | /**
|
26 | * A list item (`<li>`) spec.
|
27 | */
|
28 | export let listItem: NodeSpec;
|
29 | /**
|
30 | * Convenience function for adding list-related node types to a map
|
31 | * specifying the nodes for a schema. Adds
|
32 | * [`orderedList`](#schema-list.orderedList) as `"ordered_list"`,
|
33 | * [`bulletList`](#schema-list.bulletList) as `"bullet_list"`, and
|
34 | * [`listItem`](#schema-list.listItem) as `"list_item"`.
|
35 | *
|
36 | * `itemContent` determines the content expression for the list items.
|
37 | * If you want the commands defined in this module to apply to your
|
38 | * list structure, it should have a shape like `"paragraph block*"` or
|
39 | * `"paragraph (ordered_list | bullet_list)*"`. `listGroup` can be
|
40 | * given to assign a group name to the list node types, for example
|
41 | * `"block"`.
|
42 | */
|
43 | export function addListNodes<N extends string = any>(
|
44 | nodes: { [name in N]: NodeSpec } | OrderedMap<NodeSpec>,
|
45 | itemContent: string,
|
46 | listGroup?: string,
|
47 | ): { [name in (N | "ordered_list" | "bullet_list" | "list_item")]: NodeSpec } | OrderedMap<NodeSpec>;
|
48 | /**
|
49 | * Returns a command function that wraps the selection in a list with
|
50 | * the given type an attributes. If `dispatch` is null, only return a
|
51 | * value to indicate whether this is possible, but don't actually
|
52 | * perform the change.
|
53 | */
|
54 | export function wrapInList<S extends Schema = any>(
|
55 | listType: NodeType<S>,
|
56 | attrs?: { [key: string]: any },
|
57 | ): (state: EditorState<S>, dispatch?: (tr: Transaction<S>) => void) => boolean;
|
58 | /**
|
59 | * Build a command that splits a non-empty textblock at the top level
|
60 | * of a list item by also splitting that list item.
|
61 | */
|
62 | export function splitListItem<S extends Schema = any>(
|
63 | itemType: NodeType<S>,
|
64 | ): (state: EditorState<S>, dispatch?: (tr: Transaction<S>) => void) => boolean;
|
65 | /**
|
66 | * Create a command to lift the list item around the selection up into
|
67 | * a wrapping list.
|
68 | */
|
69 | export function liftListItem<S extends Schema = any>(
|
70 | itemType: NodeType<S>,
|
71 | ): (state: EditorState<S>, dispatch?: (tr: Transaction<S>) => void) => boolean;
|
72 | /**
|
73 | * Create a command to sink the list item around the selection down
|
74 | * into an inner list.
|
75 | */
|
76 | export function sinkListItem<S extends Schema = any>(
|
77 | itemType: NodeType<S>,
|
78 | ): (state: EditorState<S>, dispatch?: (tr: Transaction<S>) => void) => boolean;
|