Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | 416x 339x 32x 20x 9x 57x 25x 14x 9x 12x 9x 9x 22x | import type {SlateElementNode, SlateTextNode} from '../../../types';
export const txt = (text: string, marks?: Record<string, any>): SlateTextNode => ({
text,
...marks,
});
export const p = (attr: Record<string, any>, ...children: (SlateTextNode | SlateElementNode)[]): SlateElementNode => ({
...attr,
type: 'paragraph',
children: children.length ? children : [{text: ''}],
});
export const blockquote = (attr: Record<string, any>, ...children: SlateElementNode[]): SlateElementNode => ({
...attr,
type: 'blockquote',
children: children.length ? children : [{text: ''}],
});
export const ul = (...children: SlateElementNode[]): SlateElementNode => ({
type: 'bulleted_list',
children: children.length ? children : [{type: 'list_item', children: [{text: ''}]}],
});
export const ol = (order: number = 1, ...children: SlateElementNode[]): SlateElementNode => ({
type: 'ordered_list',
order,
children: children.length ? children : [{type: 'list_item', children: [{text: ''}]}],
});
export const li = (...children: (SlateTextNode | SlateElementNode)[]): SlateElementNode => ({
type: 'list_item',
children: children.length ? children : [{text: ''}],
});
export const h1 = (...children: SlateTextNode[]): SlateElementNode => ({
type: 'heading',
level: 1,
children: children.length ? children : [{text: ''}],
});
export const h2 = (...children: SlateTextNode[]): SlateElementNode => ({
type: 'heading',
level: 2,
children: children.length ? children : [{text: ''}],
});
export const h3 = (...children: SlateTextNode[]): SlateElementNode => ({
type: 'heading',
level: 3,
children: children.length ? children : [{text: ''}],
});
export const em = (text: string): SlateTextNode => ({
text,
em: true,
});
export const strong = (text: string): SlateTextNode => ({
text,
strong: true,
});
export const a = (href: string, text: string): SlateTextNode => ({
text,
href,
});
/**
* Create a void element (e.g., embed, image, horizontal rule).
* Void nodes have no user-editable content — just `children: [{text: ''}]`.
*/
export const voidNode = (type: string, attr: Record<string, any> = {}): SlateElementNode => ({
...attr,
type,
children: [{text: ''}],
});
|