@apolitical/component-library 4.1.0-beta.3 → 4.1.0-beta.4
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/context/context.d.ts +2 -0
- package/form/components/rich-text-editor/components/toolbar/components/block-option/index.d.ts +1 -0
- package/form/components/rich-text-editor/components/toolbar/components/mark-option/mark-option.helpers.d.ts +2 -0
- package/form/components/rich-text-editor/components/toolbar/index.d.ts +1 -1
- package/form/components/rich-text-editor/helpers/ast-types/ast-types.d.ts +156 -0
- package/form/components/rich-text-editor/helpers/ast-types/index.d.ts +1 -0
- package/form/components/rich-text-editor/helpers/deserialize/deserialize.d.ts +3 -0
- package/form/components/rich-text-editor/helpers/deserialize/index.d.ts +1 -0
- package/form/components/rich-text-editor/helpers/hot-keys/hot-keys.d.ts +4 -0
- package/form/components/rich-text-editor/helpers/hot-keys/index.d.ts +1 -0
- package/form/components/rich-text-editor/helpers/index.d.ts +5 -0
- package/form/components/rich-text-editor/helpers/serialize/index.d.ts +1 -0
- package/form/components/rich-text-editor/helpers/serialize/serialize.d.ts +8 -0
- package/form/components/rich-text-editor/helpers/transform/index.d.ts +1 -0
- package/form/components/rich-text-editor/helpers/transform/transform.d.ts +21 -0
- package/index.js +57 -61
- package/index.mjs +6164 -6138
- package/package.json +1 -2
- package/style.css +1 -1
- package/styles/base/_links.scss +12 -3
- package/styles/base/buttons/_icons.scss +2 -0
- package/text/markdown-text/components/span/span.d.ts +2 -1
- package/form/components/rich-text-editor/rich-text-editor.helpers.d.ts +0 -5
|
@@ -13,6 +13,8 @@ declare const RichTextEditorContext: import("react").Context<{
|
|
|
13
13
|
showLinkEditor: boolean;
|
|
14
14
|
/** The last anchor point (used for Slate to know where the cursor is) */
|
|
15
15
|
lastAnchor: Point | null;
|
|
16
|
+
/** The current selection */
|
|
17
|
+
domSelection: Selection | null;
|
|
16
18
|
/** The function to update the state */
|
|
17
19
|
dispatch: Dispatch<any>;
|
|
18
20
|
}>;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { BaseEditor } from 'slate';
|
|
2
|
+
import { MarkOptionType } from '../../../../../../../form/components/rich-text-editor/rich-text-editor.types';
|
|
3
|
+
export declare const isMarkOptionType: (value: string) => value is MarkOptionType;
|
|
2
4
|
export declare const isMarkActive: (editor: BaseEditor, format: string) => boolean;
|
|
3
5
|
export declare const toggleMark: (editor: BaseEditor, format: string) => void;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
export interface NodeTypes {
|
|
2
|
+
paragraph: string;
|
|
3
|
+
block_quote: string;
|
|
4
|
+
code_block: string;
|
|
5
|
+
link: string;
|
|
6
|
+
ul_list: string;
|
|
7
|
+
ol_list: string;
|
|
8
|
+
listItem: string;
|
|
9
|
+
heading: {
|
|
10
|
+
1: string;
|
|
11
|
+
2: string;
|
|
12
|
+
3: string;
|
|
13
|
+
4: string;
|
|
14
|
+
5: string;
|
|
15
|
+
6: string;
|
|
16
|
+
};
|
|
17
|
+
emphasis_mark: string;
|
|
18
|
+
strong_mark: string;
|
|
19
|
+
delete_mark: string;
|
|
20
|
+
inline_code_mark: string;
|
|
21
|
+
thematic_break: string;
|
|
22
|
+
image: string;
|
|
23
|
+
}
|
|
24
|
+
export type MdastNodeType = 'paragraph' | 'heading' | 'list' | 'listItem' | 'link' | 'image' | 'blockquote' | 'code' | 'html' | 'emphasis' | 'strong' | 'delete' | 'inlineCode' | 'thematicBreak' | 'text';
|
|
25
|
+
export declare const defaultNodeTypes: NodeTypes;
|
|
26
|
+
export interface LeafType {
|
|
27
|
+
text: string;
|
|
28
|
+
strikeThrough?: boolean;
|
|
29
|
+
bold?: boolean;
|
|
30
|
+
italic?: boolean;
|
|
31
|
+
code?: boolean;
|
|
32
|
+
parentType?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface BlockType {
|
|
35
|
+
type: string;
|
|
36
|
+
parentType?: string;
|
|
37
|
+
link?: string;
|
|
38
|
+
caption?: string;
|
|
39
|
+
language?: string;
|
|
40
|
+
break?: boolean;
|
|
41
|
+
children: Array<BlockType | LeafType>;
|
|
42
|
+
}
|
|
43
|
+
export interface InputNodeTypes {
|
|
44
|
+
paragraph: string;
|
|
45
|
+
block_quote: string;
|
|
46
|
+
code_block: string;
|
|
47
|
+
link: string;
|
|
48
|
+
ul_list: string;
|
|
49
|
+
ol_list: string;
|
|
50
|
+
listItem: string;
|
|
51
|
+
heading: {
|
|
52
|
+
1: string;
|
|
53
|
+
2: string;
|
|
54
|
+
3: string;
|
|
55
|
+
4: string;
|
|
56
|
+
5: string;
|
|
57
|
+
6: string;
|
|
58
|
+
};
|
|
59
|
+
emphasis_mark: string;
|
|
60
|
+
strong_mark: string;
|
|
61
|
+
delete_mark: string;
|
|
62
|
+
inline_code_mark: string;
|
|
63
|
+
thematic_break: string;
|
|
64
|
+
image: string;
|
|
65
|
+
}
|
|
66
|
+
type RecursivePartial<T> = {
|
|
67
|
+
[P in keyof T]?: RecursivePartial<T[P]>;
|
|
68
|
+
};
|
|
69
|
+
export interface OptionType<T extends InputNodeTypes = InputNodeTypes> {
|
|
70
|
+
nodeTypes?: RecursivePartial<T>;
|
|
71
|
+
linkDestinationKey?: string;
|
|
72
|
+
imageSourceKey?: string;
|
|
73
|
+
imageCaptionKey?: string;
|
|
74
|
+
}
|
|
75
|
+
export interface MdastNode {
|
|
76
|
+
type?: MdastNodeType;
|
|
77
|
+
ordered?: boolean;
|
|
78
|
+
value?: string;
|
|
79
|
+
text?: string;
|
|
80
|
+
children?: Array<MdastNode>;
|
|
81
|
+
depth?: 1 | 2 | 3 | 4 | 5 | 6;
|
|
82
|
+
url?: string;
|
|
83
|
+
alt?: string;
|
|
84
|
+
lang?: string;
|
|
85
|
+
position?: any;
|
|
86
|
+
spread?: any;
|
|
87
|
+
checked?: any;
|
|
88
|
+
indent?: any;
|
|
89
|
+
}
|
|
90
|
+
export type TextNode = {
|
|
91
|
+
text?: string | undefined;
|
|
92
|
+
};
|
|
93
|
+
export type CodeBlockNode<T extends InputNodeTypes> = {
|
|
94
|
+
type: T['code_block'];
|
|
95
|
+
language: string | undefined;
|
|
96
|
+
children: Array<TextNode>;
|
|
97
|
+
};
|
|
98
|
+
export type HeadingNode<T extends InputNodeTypes> = {
|
|
99
|
+
type: T['heading'][1] | T['heading'][2] | T['heading'][3] | T['heading'][4] | T['heading'][5] | T['heading'][6];
|
|
100
|
+
children: Array<DeserializedNode<T>>;
|
|
101
|
+
};
|
|
102
|
+
export type ListNode<T extends InputNodeTypes> = {
|
|
103
|
+
type: T['ol_list'] | T['ul_list'];
|
|
104
|
+
children: Array<DeserializedNode<T>>;
|
|
105
|
+
};
|
|
106
|
+
export type ListItemNode<T extends InputNodeTypes> = {
|
|
107
|
+
type: T['listItem'];
|
|
108
|
+
children: Array<DeserializedNode<T>>;
|
|
109
|
+
};
|
|
110
|
+
export type ParagraphNode<T extends InputNodeTypes> = {
|
|
111
|
+
type: T['paragraph'];
|
|
112
|
+
break?: true;
|
|
113
|
+
children: Array<DeserializedNode<T>>;
|
|
114
|
+
};
|
|
115
|
+
export type LinkNode<T extends InputNodeTypes> = {
|
|
116
|
+
type: T['link'];
|
|
117
|
+
children: Array<DeserializedNode<T>>;
|
|
118
|
+
[urlKey: string]: string | undefined | Array<DeserializedNode<T>>;
|
|
119
|
+
};
|
|
120
|
+
export type ImageNode<T extends InputNodeTypes> = {
|
|
121
|
+
type: T['image'];
|
|
122
|
+
children: Array<DeserializedNode<T>>;
|
|
123
|
+
[sourceOrCaptionKey: string]: string | undefined | Array<DeserializedNode<T>>;
|
|
124
|
+
};
|
|
125
|
+
export type BlockQuoteNode<T extends InputNodeTypes> = {
|
|
126
|
+
type: T['block_quote'];
|
|
127
|
+
children: Array<DeserializedNode<T>>;
|
|
128
|
+
};
|
|
129
|
+
export type InlineCodeMarkNode<T extends InputNodeTypes> = {
|
|
130
|
+
type: T['inline_code_mark'];
|
|
131
|
+
children: Array<TextNode>;
|
|
132
|
+
language: string | undefined;
|
|
133
|
+
};
|
|
134
|
+
export type ThematicBreakNode<T extends InputNodeTypes> = {
|
|
135
|
+
type: T['thematic_break'];
|
|
136
|
+
children: Array<DeserializedNode<T>>;
|
|
137
|
+
};
|
|
138
|
+
export type ItalicNode<T extends InputNodeTypes> = {
|
|
139
|
+
[K in T['emphasis_mark']]: true;
|
|
140
|
+
} & {
|
|
141
|
+
children: TextNode;
|
|
142
|
+
};
|
|
143
|
+
export type BoldNode = {
|
|
144
|
+
bold: true;
|
|
145
|
+
children: TextNode;
|
|
146
|
+
};
|
|
147
|
+
export type StrikeThoughNode = {
|
|
148
|
+
strikeThrough: true;
|
|
149
|
+
children: TextNode;
|
|
150
|
+
};
|
|
151
|
+
export type InlineCodeNode = {
|
|
152
|
+
code: true;
|
|
153
|
+
text: string | undefined;
|
|
154
|
+
};
|
|
155
|
+
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;
|
|
156
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ast-types';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as deserialize } from './deserialize';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as HOTKEYS } from './hot-keys';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as serialize } from './serialize';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BlockType, LeafType, NodeTypes } from './../ast-types';
|
|
2
|
+
interface Options {
|
|
3
|
+
nodeTypes: NodeTypes;
|
|
4
|
+
listDepth?: number;
|
|
5
|
+
ignoreParagraphNewline?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export default function serialize(chunk: BlockType | LeafType, opts?: Options): string | undefined;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as transform } from './transform';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BlockQuoteNode, CodeBlockNode, HeadingNode, ImageNode, InputNodeTypes, ItalicNode, LinkNode, ListItemNode, ListNode, MdastNode, OptionType, ParagraphNode, ThematicBreakNode } from './../ast-types';
|
|
2
|
+
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: string;
|
|
4
|
+
children: {
|
|
5
|
+
text: string;
|
|
6
|
+
}[];
|
|
7
|
+
} | {
|
|
8
|
+
value?: string | undefined;
|
|
9
|
+
position?: any;
|
|
10
|
+
url?: string | undefined;
|
|
11
|
+
alt?: string | undefined;
|
|
12
|
+
checked?: any;
|
|
13
|
+
ordered?: boolean | undefined;
|
|
14
|
+
depth?: 1 | 2 | 3 | 4 | 5 | 6 | undefined;
|
|
15
|
+
lang?: string | undefined;
|
|
16
|
+
spread?: any;
|
|
17
|
+
indent?: any;
|
|
18
|
+
text: string | undefined;
|
|
19
|
+
type?: undefined;
|
|
20
|
+
children?: undefined;
|
|
21
|
+
};
|