@apolitical/component-library 4.1.4 → 4.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/form/components/rich-text-editor/components/toolbar/toolbar.data.d.ts +1 -1
- package/form/components/rich-text-editor/helpers/ast-types/ast-types.d.ts +65 -47
- package/form/components/rich-text-editor/helpers/transform/transform.d.ts +2 -1
- package/form/components/rich-text-editor/rich-text-editor.types.d.ts +29 -6
- package/index.js +59 -59
- package/index.mjs +5310 -5296
- package/package.json +1 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { BlockOptionType, MarkOptionType } from '
|
|
1
|
+
import { BlockOptionType, MarkOptionType } from './../../rich-text-editor.types';
|
|
2
2
|
export declare const marks: MarkOptionType[];
|
|
3
3
|
export declare const blocks: BlockOptionType[];
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { Formatting, Marks } from './../../rich-text-editor.types';
|
|
1
2
|
export interface NodeTypes {
|
|
2
|
-
paragraph: string;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
link: string;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
heading: {
|
|
3
|
+
[Formatting.paragraph]: string;
|
|
4
|
+
[Formatting.blockquote]: string;
|
|
5
|
+
[Formatting.codeblock]: string;
|
|
6
|
+
[Formatting.link]: string;
|
|
7
|
+
[Formatting.ul]: string;
|
|
8
|
+
[Formatting.ol]: string;
|
|
9
|
+
[Formatting.li]: string;
|
|
10
|
+
[Formatting.heading]: {
|
|
10
11
|
1: string;
|
|
11
12
|
2: string;
|
|
12
13
|
3: string;
|
|
@@ -14,21 +15,38 @@ export interface NodeTypes {
|
|
|
14
15
|
5: string;
|
|
15
16
|
6: string;
|
|
16
17
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
image: string;
|
|
18
|
+
[Marks.emphasis]: string;
|
|
19
|
+
[Marks.strong]: string;
|
|
20
|
+
[Marks.delete]: string;
|
|
21
|
+
[Marks.code]: string;
|
|
22
|
+
[Formatting.hr]: string;
|
|
23
|
+
[Formatting.image]: string;
|
|
23
24
|
}
|
|
24
|
-
export
|
|
25
|
+
export declare enum MdastNodes {
|
|
26
|
+
paragraph = "paragraph",
|
|
27
|
+
heading = "heading",
|
|
28
|
+
list = "list",
|
|
29
|
+
listItem = "listItem",
|
|
30
|
+
link = "link",
|
|
31
|
+
image = "image",
|
|
32
|
+
blockquote = "blockquote",
|
|
33
|
+
code = "code",
|
|
34
|
+
html = "html",
|
|
35
|
+
emphasis = "emphasis",
|
|
36
|
+
strong = "strong",
|
|
37
|
+
delete = "delete",
|
|
38
|
+
inlineCode = "inlineCode",
|
|
39
|
+
thematicBreak = "thematicBreak",
|
|
40
|
+
text = "text"
|
|
41
|
+
}
|
|
42
|
+
export type MdastNodeType = MdastNodes.paragraph | MdastNodes.heading | MdastNodes.list | MdastNodes.listItem | MdastNodes.link | MdastNodes.image | MdastNodes.blockquote | MdastNodes.code | MdastNodes.html | MdastNodes.emphasis | MdastNodes.strong | MdastNodes.delete | MdastNodes.inlineCode | MdastNodes.thematicBreak | MdastNodes.text;
|
|
25
43
|
export declare const defaultNodeTypes: NodeTypes;
|
|
26
44
|
export interface LeafType {
|
|
27
45
|
text: string;
|
|
28
|
-
|
|
29
|
-
bold?: boolean;
|
|
30
|
-
italic?: boolean;
|
|
31
|
-
code?: boolean;
|
|
46
|
+
[Formatting.strikethrough]?: boolean;
|
|
47
|
+
[Formatting.bold]?: boolean;
|
|
48
|
+
[Formatting.italic]?: boolean;
|
|
49
|
+
[Formatting.code]?: boolean;
|
|
32
50
|
parentType?: string;
|
|
33
51
|
}
|
|
34
52
|
export interface BlockType {
|
|
@@ -41,14 +59,14 @@ export interface BlockType {
|
|
|
41
59
|
children: Array<BlockType | LeafType>;
|
|
42
60
|
}
|
|
43
61
|
export interface InputNodeTypes {
|
|
44
|
-
paragraph: string;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
link: string;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
heading: {
|
|
62
|
+
[Formatting.paragraph]: string;
|
|
63
|
+
[Formatting.blockquote]: string;
|
|
64
|
+
[Formatting.codeblock]: string;
|
|
65
|
+
[Formatting.link]: string;
|
|
66
|
+
[Formatting.ul]: string;
|
|
67
|
+
[Formatting.ol]: string;
|
|
68
|
+
[Formatting.li]: string;
|
|
69
|
+
[Formatting.heading]: {
|
|
52
70
|
1: string;
|
|
53
71
|
2: string;
|
|
54
72
|
3: string;
|
|
@@ -56,12 +74,12 @@ export interface InputNodeTypes {
|
|
|
56
74
|
5: string;
|
|
57
75
|
6: string;
|
|
58
76
|
};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
image: string;
|
|
77
|
+
[Marks.emphasis]: string;
|
|
78
|
+
[Marks.strong]: string;
|
|
79
|
+
[Marks.delete]: string;
|
|
80
|
+
[Marks.code]: string;
|
|
81
|
+
[Formatting.hr]: string;
|
|
82
|
+
[Formatting.image]: string;
|
|
65
83
|
}
|
|
66
84
|
type RecursivePartial<T> = {
|
|
67
85
|
[P in keyof T]?: RecursivePartial<T[P]>;
|
|
@@ -91,65 +109,65 @@ export type TextNode = {
|
|
|
91
109
|
text?: string | undefined;
|
|
92
110
|
};
|
|
93
111
|
export type CodeBlockNode<T extends InputNodeTypes> = {
|
|
94
|
-
type: T[
|
|
112
|
+
type: T[Formatting.codeblock];
|
|
95
113
|
language: string | undefined;
|
|
96
114
|
children: Array<TextNode>;
|
|
97
115
|
};
|
|
98
116
|
export type HeadingNode<T extends InputNodeTypes> = {
|
|
99
|
-
type: T[
|
|
117
|
+
type: T[Formatting.heading][1] | T[Formatting.heading][2] | T[Formatting.heading][3] | T[Formatting.heading][4] | T[Formatting.heading][5] | T[Formatting.heading][6];
|
|
100
118
|
children: Array<DeserializedNode<T>>;
|
|
101
119
|
};
|
|
102
120
|
export type ListNode<T extends InputNodeTypes> = {
|
|
103
|
-
type: T[
|
|
121
|
+
type: T[Formatting.ol] | T[Formatting.ul];
|
|
104
122
|
children: Array<DeserializedNode<T>>;
|
|
105
123
|
};
|
|
106
124
|
export type ListItemNode<T extends InputNodeTypes> = {
|
|
107
|
-
type: T[
|
|
125
|
+
type: T[Formatting.li];
|
|
108
126
|
children: Array<DeserializedNode<T>>;
|
|
109
127
|
};
|
|
110
128
|
export type ParagraphNode<T extends InputNodeTypes> = {
|
|
111
|
-
type: T[
|
|
129
|
+
type: T[Formatting.paragraph];
|
|
112
130
|
break?: true;
|
|
113
131
|
children: Array<DeserializedNode<T>>;
|
|
114
132
|
};
|
|
115
133
|
export type LinkNode<T extends InputNodeTypes> = {
|
|
116
|
-
type: T[
|
|
134
|
+
type: T[Formatting.link];
|
|
117
135
|
children: Array<DeserializedNode<T>>;
|
|
118
136
|
[urlKey: string]: string | undefined | Array<DeserializedNode<T>>;
|
|
119
137
|
};
|
|
120
138
|
export type ImageNode<T extends InputNodeTypes> = {
|
|
121
|
-
type: T[
|
|
139
|
+
type: T[Formatting.image];
|
|
122
140
|
children: Array<DeserializedNode<T>>;
|
|
123
141
|
[sourceOrCaptionKey: string]: string | undefined | Array<DeserializedNode<T>>;
|
|
124
142
|
};
|
|
125
143
|
export type BlockQuoteNode<T extends InputNodeTypes> = {
|
|
126
|
-
type: T[
|
|
144
|
+
type: T[Formatting.blockquote];
|
|
127
145
|
children: Array<DeserializedNode<T>>;
|
|
128
146
|
};
|
|
129
147
|
export type InlineCodeMarkNode<T extends InputNodeTypes> = {
|
|
130
|
-
type: T[
|
|
148
|
+
type: T[Marks.code];
|
|
131
149
|
children: Array<TextNode>;
|
|
132
150
|
language: string | undefined;
|
|
133
151
|
};
|
|
134
152
|
export type ThematicBreakNode<T extends InputNodeTypes> = {
|
|
135
|
-
type: T[
|
|
153
|
+
type: T[Formatting.hr];
|
|
136
154
|
children: Array<DeserializedNode<T>>;
|
|
137
155
|
};
|
|
138
156
|
export type ItalicNode<T extends InputNodeTypes> = {
|
|
139
|
-
[K in T[
|
|
157
|
+
[K in T[Marks.emphasis]]: true;
|
|
140
158
|
} & {
|
|
141
159
|
children: TextNode;
|
|
142
160
|
};
|
|
143
161
|
export type BoldNode = {
|
|
144
|
-
bold: true;
|
|
162
|
+
[Formatting.bold]: true;
|
|
145
163
|
children: TextNode;
|
|
146
164
|
};
|
|
147
165
|
export type StrikeThoughNode = {
|
|
148
|
-
|
|
166
|
+
[Formatting.strikethrough]: true;
|
|
149
167
|
children: TextNode;
|
|
150
168
|
};
|
|
151
169
|
export type InlineCodeNode = {
|
|
152
|
-
code: true;
|
|
170
|
+
[Formatting.code]: true;
|
|
153
171
|
text: string | undefined;
|
|
154
172
|
};
|
|
155
173
|
export type DeserializedNode<T extends InputNodeTypes> = CodeBlockNode<T> | HeadingNode<T> | ListNode<T> | ListItemNode<T> | ParagraphNode<T> | LinkNode<T> | ImageNode<T> | BlockQuoteNode<T> | InlineCodeMarkNode<T> | ThematicBreakNode<T> | ItalicNode<T> | BoldNode | StrikeThoughNode | InlineCodeNode | TextNode;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { Formatting } from './../../rich-text-editor.types';
|
|
1
2
|
import { BlockQuoteNode, CodeBlockNode, HeadingNode, ImageNode, InputNodeTypes, ItalicNode, LinkNode, ListItemNode, ListNode, MdastNode, OptionType, ParagraphNode, ThematicBreakNode } from './../ast-types';
|
|
2
3
|
export default function transform<T extends InputNodeTypes>(node: MdastNode, opts?: OptionType<T>): CodeBlockNode<T> | HeadingNode<T> | ListNode<T> | ListItemNode<T> | ParagraphNode<T> | LinkNode<T> | ImageNode<T> | BlockQuoteNode<T> | ThematicBreakNode<T> | ItalicNode<T> | {
|
|
3
|
-
type:
|
|
4
|
+
type: Formatting;
|
|
4
5
|
children: {
|
|
5
6
|
text: string;
|
|
6
7
|
}[];
|
|
@@ -1,24 +1,47 @@
|
|
|
1
1
|
import { BaseElement, BaseText, Descendant } from 'slate';
|
|
2
|
+
export declare enum Formatting {
|
|
3
|
+
blockquote = "block_quote",
|
|
4
|
+
bold = "bold",
|
|
5
|
+
code = "code",
|
|
6
|
+
codeblock = "code_block",
|
|
7
|
+
heading = "heading",
|
|
8
|
+
hr = "thematic_break",
|
|
9
|
+
image = "image",
|
|
10
|
+
italic = "italic",
|
|
11
|
+
li = "list_item",
|
|
12
|
+
link = "link",
|
|
13
|
+
ol = "ol_list",
|
|
14
|
+
paragraph = "paragraph",
|
|
15
|
+
ul = "ul_list",
|
|
16
|
+
strikethrough = "strikeThrough",
|
|
17
|
+
span = "span"
|
|
18
|
+
}
|
|
19
|
+
export declare enum Marks {
|
|
20
|
+
delete = "delete_mark",
|
|
21
|
+
emphasis = "emphasis_mark",
|
|
22
|
+
code = "inline_code_mark",
|
|
23
|
+
strong = "strong_mark"
|
|
24
|
+
}
|
|
2
25
|
export interface BaseProps {
|
|
3
26
|
className?: string;
|
|
4
27
|
[key: string]: unknown;
|
|
5
28
|
}
|
|
6
|
-
export type BlockOptionType =
|
|
29
|
+
export type BlockOptionType = Formatting.blockquote | Formatting.link | Formatting.li | Formatting.ol | Formatting.ul | Formatting.paragraph | Formatting.span;
|
|
7
30
|
export interface TypeElement extends BaseElement {
|
|
8
31
|
type: BlockOptionType;
|
|
9
32
|
}
|
|
10
|
-
export type MarkOptionType =
|
|
33
|
+
export type MarkOptionType = Formatting.bold | Formatting.italic | Formatting.strikethrough;
|
|
11
34
|
export interface TypeText extends BaseText {
|
|
12
|
-
bold?: boolean;
|
|
13
|
-
italic?: boolean;
|
|
14
|
-
|
|
35
|
+
[Formatting.bold]?: boolean;
|
|
36
|
+
[Formatting.italic]?: boolean;
|
|
37
|
+
[Formatting.strikethrough]?: boolean;
|
|
15
38
|
}
|
|
16
39
|
export type OptionTypes = {
|
|
17
40
|
format: BlockOptionType | MarkOptionType;
|
|
18
41
|
hasDivider?: boolean;
|
|
19
42
|
};
|
|
20
43
|
export type LinkElement = {
|
|
21
|
-
type:
|
|
44
|
+
type: Formatting.link;
|
|
22
45
|
link: string;
|
|
23
46
|
children: Descendant[];
|
|
24
47
|
};
|