@apolitical/component-library 4.0.6 → 4.1.0-beta.10
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/accessibility/visually-hidden/visually-hidden.d.ts +19 -1
- package/discussion/components/form/form.d.ts +3 -6
- package/discussion/components/likes/likes.d.ts +7 -1
- package/form/components/form/components/field-wrapper/field-wrapper.d.ts +1 -1
- package/form/components/form/components/fields/checkbox/checkbox.d.ts +4 -0
- package/form/components/form/components/fields/input/input.d.ts +4 -0
- package/form/components/form/form.d.ts +1 -1
- package/form/components/form/form.types.d.ts +11 -1
- package/form/components/index.d.ts +1 -0
- package/form/components/rich-text-editor/components/context/context.d.ts +19 -0
- package/form/components/rich-text-editor/components/context/index.d.ts +1 -0
- package/form/components/rich-text-editor/components/editor/element/element.d.ts +3 -0
- package/form/components/rich-text-editor/components/editor/element/index.d.ts +1 -0
- package/form/components/rich-text-editor/components/editor/index.d.ts +2 -0
- package/form/components/rich-text-editor/components/editor/leaf/index.d.ts +1 -0
- package/form/components/rich-text-editor/components/editor/leaf/leaf.d.ts +3 -0
- package/form/components/rich-text-editor/components/index.d.ts +3 -0
- package/form/components/rich-text-editor/components/toolbar/components/block-option/block-option.d.ts +3 -0
- package/form/components/rich-text-editor/components/toolbar/components/block-option/block-option.helpers.d.ts +3 -0
- package/form/components/rich-text-editor/components/toolbar/components/block-option/index.d.ts +2 -0
- package/form/components/rich-text-editor/components/toolbar/components/index.d.ts +4 -0
- package/form/components/rich-text-editor/components/toolbar/components/link-editor/index.d.ts +2 -0
- package/form/components/rich-text-editor/components/toolbar/components/link-editor/link-editor.d.ts +2 -0
- package/form/components/rich-text-editor/components/toolbar/components/link-editor/link-editor.helpers.d.ts +5 -0
- package/form/components/rich-text-editor/components/toolbar/components/link-option/index.d.ts +1 -0
- package/form/components/rich-text-editor/components/toolbar/components/link-option/link-option.d.ts +2 -0
- package/form/components/rich-text-editor/components/toolbar/components/mark-option/index.d.ts +2 -0
- package/form/components/rich-text-editor/components/toolbar/components/mark-option/mark-option.d.ts +3 -0
- package/form/components/rich-text-editor/components/toolbar/components/mark-option/mark-option.helpers.d.ts +5 -0
- package/form/components/rich-text-editor/components/toolbar/components/option/index.d.ts +1 -0
- package/form/components/rich-text-editor/components/toolbar/components/option/option.d.ts +15 -0
- package/form/components/rich-text-editor/components/toolbar/index.d.ts +3 -0
- package/form/components/rich-text-editor/components/toolbar/toolbar.d.ts +4 -0
- package/form/components/rich-text-editor/components/toolbar/toolbar.data.d.ts +3 -0
- 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/helpers.data.d.ts +97 -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/do-serialize.d.ts +3 -0
- package/form/components/rich-text-editor/helpers/serialize/index.d.ts +2 -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/form/components/rich-text-editor/hooks/index.d.ts +2 -0
- package/form/components/rich-text-editor/hooks/use-positioned-element/index.d.ts +1 -0
- package/form/components/rich-text-editor/hooks/use-positioned-element/use-positioned-element.d.ts +4 -0
- package/form/components/rich-text-editor/hooks/use-selected-link/index.d.ts +1 -0
- package/form/components/rich-text-editor/hooks/use-selected-link/use-selected-link.d.ts +6 -0
- package/form/components/rich-text-editor/index.d.ts +1 -0
- package/form/components/rich-text-editor/plugins/index.d.ts +1 -0
- package/form/components/rich-text-editor/plugins/with-linlines/index.d.ts +1 -0
- package/form/components/rich-text-editor/plugins/with-linlines/with-inlines.d.ts +5 -0
- package/form/components/rich-text-editor/rich-text-editor.d.ts +18 -0
- package/form/components/rich-text-editor/rich-text-editor.types.d.ts +24 -0
- package/general/buttons/button/button.d.ts +7 -1
- package/general/buttons/button-wrapper/button-wrapper.d.ts +5 -1
- package/general/index.d.ts +1 -0
- package/general/link/link.d.ts +6 -0
- package/general/portal/index.d.ts +1 -0
- package/general/portal/portal.d.ts +5 -0
- package/general/tooltip/tooltip.d.ts +27 -1
- package/helpers/intl.d.ts +17 -0
- package/helpers/validation.d.ts +1 -1
- package/index.js +116 -21
- package/index.mjs +19386 -5809
- package/package.json +11 -3
- package/style.css +1 -1
- package/styles/base/_accessibility.scss +5 -0
- package/styles/base/_links.scss +12 -3
- package/styles/base/form/_fields.scss +1 -1
- package/styles/variables/colors/theme/_form.scss +10 -0
- package/testing/__mocks__/remark-parse.d.ts +2 -0
- package/testing/__mocks__/unified.d.ts +6 -0
- package/text/markdown-text/components/span/span.d.ts +2 -1
|
@@ -1,28 +1,46 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
interface Props {
|
|
3
3
|
/** The element that will render around the content. */
|
|
4
|
-
element?: 'span' | 'small' | 'strong' | 'em' | 'sup' | 'sub' | 'div' | 'p' | 'label' | 'a' | 'button';
|
|
4
|
+
element?: 'span' | 'small' | 'strong' | 'em' | 'sup' | 'sub' | 'div' | 'p' | 'label' | 'legend' | 'a' | 'button';
|
|
5
5
|
/** Whether the content should be shown on focus. */
|
|
6
6
|
showOnFocus?: boolean;
|
|
7
7
|
/** The content to be hidden from screen readers. */
|
|
8
8
|
children: React.ReactNode | JSX.Element | string;
|
|
9
9
|
/** An `href`, for links */
|
|
10
10
|
href?: string;
|
|
11
|
+
/** An `onBlur`, for buttons */
|
|
12
|
+
onBlur?: (e: React.FocusEvent) => void;
|
|
11
13
|
/** An `onClick`, for buttons */
|
|
12
14
|
onClick?: (e: React.MouseEvent) => void;
|
|
15
|
+
/** An `onFocus`, for buttons */
|
|
16
|
+
onFocus?: (e: React.FocusEvent) => void;
|
|
17
|
+
/** An `onKeyDown`, for buttons */
|
|
18
|
+
onKeyDown?: (e: React.KeyboardEvent) => void;
|
|
13
19
|
/** `for`, for labels */
|
|
14
20
|
htmlFor?: string;
|
|
15
21
|
/** Additional classes */
|
|
16
22
|
className?: string;
|
|
23
|
+
/** Additional aria props */
|
|
24
|
+
'aria-expanded'?: boolean;
|
|
25
|
+
'aria-controls'?: string;
|
|
17
26
|
}
|
|
18
27
|
declare const _default: React.MemoExoticComponent<({ element, showOnFocus, children, className, ...props }: Props) => React.DetailedReactHTMLElement<{
|
|
19
28
|
className: string;
|
|
20
29
|
children: React.ReactNode | JSX.Element;
|
|
21
30
|
/** An `href`, for links */
|
|
22
31
|
href?: string | undefined;
|
|
32
|
+
/** An `onBlur`, for buttons */
|
|
33
|
+
onBlur?: ((e: React.FocusEvent<Element, Element>) => void) | undefined;
|
|
23
34
|
/** An `onClick`, for buttons */
|
|
24
35
|
onClick?: ((e: React.MouseEvent<Element, MouseEvent>) => void) | undefined;
|
|
36
|
+
/** An `onFocus`, for buttons */
|
|
37
|
+
onFocus?: ((e: React.FocusEvent<Element, Element>) => void) | undefined;
|
|
38
|
+
/** An `onKeyDown`, for buttons */
|
|
39
|
+
onKeyDown?: ((e: React.KeyboardEvent<Element>) => void) | undefined;
|
|
25
40
|
/** `for`, for labels */
|
|
26
41
|
htmlFor?: string | undefined;
|
|
42
|
+
/** Additional aria props */
|
|
43
|
+
'aria-expanded'?: boolean | undefined;
|
|
44
|
+
'aria-controls'?: string | undefined;
|
|
27
45
|
}, HTMLElement>>;
|
|
28
46
|
export default _default;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { DiscussionCreateContentFunction, IDiscussionContent } from './../../discussion';
|
|
3
2
|
export interface IDiscussionForm {
|
|
3
|
+
/** A unique ID for the form */
|
|
4
|
+
id?: string;
|
|
4
5
|
/** Information about the content being created/edited */
|
|
5
6
|
content: IDiscussionContent;
|
|
6
7
|
/** If the user has permission to interact with the form, e.g. if they're a member of the community */
|
|
@@ -20,14 +21,10 @@ export interface IDiscussionForm {
|
|
|
20
21
|
/** Whether the success message should show on a successful submit */
|
|
21
22
|
showSuccessMessage?: boolean;
|
|
22
23
|
};
|
|
23
|
-
/** The `ref` for the input, if we need to have control over it in the parent */
|
|
24
|
-
inputRef?: React.Ref<HTMLTextAreaElement> | undefined;
|
|
25
24
|
/** The placeholder text - this defaults to the intl text */
|
|
26
25
|
placeholder?: string;
|
|
27
26
|
/** The maximum number of characters */
|
|
28
27
|
maxLength?: number;
|
|
29
|
-
/** The minimum number of rows */
|
|
30
|
-
minRows?: number;
|
|
31
28
|
/** Force elements on the form to show, regardless of the form state */
|
|
32
29
|
forceShow?: {
|
|
33
30
|
/** If the cancel button should always show */
|
|
@@ -52,5 +49,5 @@ export interface IDiscussionForm {
|
|
|
52
49
|
/** The language to use for the text */
|
|
53
50
|
locale?: string;
|
|
54
51
|
}
|
|
55
|
-
declare const Form: ({ content, userHasPermissions, meta,
|
|
52
|
+
declare const Form: ({ id, content, userHasPermissions, meta, placeholder, maxLength, forceShow, functions, gtmContext, }: IDiscussionForm) => import("react/jsx-runtime").JSX.Element;
|
|
56
53
|
export default Form;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { MemberProps } from '../../../user';
|
|
2
3
|
import { IDiscussionContent } from './../../discussion';
|
|
3
4
|
interface Props {
|
|
@@ -25,5 +26,10 @@ interface Props {
|
|
|
25
26
|
/** The language to use for the text */
|
|
26
27
|
locale?: string;
|
|
27
28
|
}
|
|
28
|
-
declare const Likes: ({ element, likes, peopleWhoLiked, isShort, userLiked, content, canLike, functions: { createLike, deleteLike }, }: Props) =>
|
|
29
|
+
declare const Likes: ({ element, likes, peopleWhoLiked, isShort, userLiked, content, canLike, functions: { createLike, deleteLike }, }: Props) => React.DetailedReactHTMLElement<{
|
|
30
|
+
className: string;
|
|
31
|
+
onKeyDown: (e: React.KeyboardEvent<HTMLElement>) => void;
|
|
32
|
+
onMouseEnter: () => void;
|
|
33
|
+
onMouseLeave: () => void;
|
|
34
|
+
}, HTMLElement>;
|
|
29
35
|
export default Likes;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { IFieldWrapper } from '../../form.types';
|
|
2
|
-
declare const FieldWrapper: ({ id, intlPath, className, error, functions, limit, showRequiredLabels, type, validation, value, ...props }: IFieldWrapper) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
declare const FieldWrapper: ({ id, intlPath, className, error, functions, limit, showRequiredLabels, type, validation, value, submitOnEnter, ...props }: IFieldWrapper) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default FieldWrapper;
|
|
@@ -5,10 +5,13 @@ export declare const Checkbox: ({ className, disabled, element, functions: allFu
|
|
|
5
5
|
onBlur?: (() => void) | undefined;
|
|
6
6
|
onFocus?: (() => void) | undefined;
|
|
7
7
|
onKeyInput?: (<T>(arg1: import("../../../form.types").FormValues) => Promise<T>) | undefined;
|
|
8
|
+
onKeyDown?: ((e: React.KeyboardEvent<HTMLElement>) => void) | undefined;
|
|
9
|
+
submitForm?: ((arg: import("../../../form.types").IFormValues) => void) | undefined;
|
|
8
10
|
'aria-describedby'?: string | undefined;
|
|
9
11
|
'aria-invalid'?: boolean | undefined;
|
|
10
12
|
'aria-required'?: boolean | undefined;
|
|
11
13
|
autoComplete?: string | undefined;
|
|
14
|
+
autoFocus?: boolean | undefined;
|
|
12
15
|
component?: any;
|
|
13
16
|
'data-character-limit'?: number | undefined;
|
|
14
17
|
'data-testid'?: string | undefined;
|
|
@@ -30,6 +33,7 @@ export declare const Checkbox: ({ className, disabled, element, functions: allFu
|
|
|
30
33
|
[key: string]: string | boolean | object | React.RefObject<any> | (() => void);
|
|
31
34
|
} | undefined;
|
|
32
35
|
required?: boolean | undefined;
|
|
36
|
+
submitOnEnter?: boolean | undefined;
|
|
33
37
|
validation?: import("../../../form.types").IFieldValidation[] | undefined;
|
|
34
38
|
onClick: (e: React.MouseEvent<HTMLElement>) => void;
|
|
35
39
|
className: string;
|
|
@@ -6,6 +6,8 @@ export declare const Input: ({ className, element, id, inputRef: ref, functions,
|
|
|
6
6
|
onBlur?: (() => void) | undefined;
|
|
7
7
|
onFocus?: (() => void) | undefined;
|
|
8
8
|
onKeyInput?: (<T>(arg1: import("../../../form.types").FormValues) => Promise<T>) | undefined;
|
|
9
|
+
onKeyDown?: ((e: React.KeyboardEvent<HTMLElement>) => void) | undefined;
|
|
10
|
+
submitForm?: ((arg: import("../../../form.types").IFormValues) => void) | undefined;
|
|
9
11
|
type: InputTypes;
|
|
10
12
|
id: string | undefined;
|
|
11
13
|
name: string | undefined;
|
|
@@ -16,6 +18,7 @@ export declare const Input: ({ className, element, id, inputRef: ref, functions,
|
|
|
16
18
|
'aria-invalid'?: boolean | undefined;
|
|
17
19
|
'aria-required'?: boolean | undefined;
|
|
18
20
|
autoComplete?: string | undefined;
|
|
21
|
+
autoFocus?: boolean | undefined;
|
|
19
22
|
component?: any;
|
|
20
23
|
'data-character-limit'?: number | undefined;
|
|
21
24
|
'data-testid'?: string | undefined;
|
|
@@ -39,6 +42,7 @@ export declare const Input: ({ className, element, id, inputRef: ref, functions,
|
|
|
39
42
|
} | undefined;
|
|
40
43
|
required?: boolean | undefined;
|
|
41
44
|
shownValue?: InputValues | undefined;
|
|
45
|
+
submitOnEnter?: boolean | undefined;
|
|
42
46
|
validation?: import("../../../form.types").IFieldValidation[] | undefined;
|
|
43
47
|
ref: React.RefObject<HTMLInputElement>;
|
|
44
48
|
}, HTMLInputElement>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { IFormProps } from './form.types';
|
|
2
|
-
declare const Form: ({ fields, className, id: formId, formRef: ref, intlPath, button, secondaryActionButton, meta, gtm, functions: { onSuccess, onCancel, onCatch, onFailure, }, ...props }: IFormProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
2
|
+
declare const Form: ({ element, fields, className, id: formId, formRef: ref, intlPath, button, secondaryActionButton, meta, gtm, functions: { onSuccess, onCancel, onCatch, onFailure, }, ...props }: IFormProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
3
3
|
export default Form;
|
|
@@ -5,7 +5,7 @@ import { IntlShape } from 'react-intl';
|
|
|
5
5
|
export type InputValues = string | number | boolean | null;
|
|
6
6
|
export type MultipleInputValues = InputValues[];
|
|
7
7
|
export type FormValues = InputValues | MultipleInputValues | undefined;
|
|
8
|
-
export type InputTypes = 'text' | 'textarea' | 'email' | 'checkbox' | 'select' | 'radio' | 'password' | 'autocomplete' | 'number';
|
|
8
|
+
export type InputTypes = 'text' | 'textarea' | 'email' | 'url' | 'checkbox' | 'select' | 'radio' | 'password' | 'autocomplete' | 'number';
|
|
9
9
|
export interface ILabel {
|
|
10
10
|
/** The element to be used, defaulting to `label` */
|
|
11
11
|
element?: string;
|
|
@@ -68,6 +68,8 @@ export interface IField {
|
|
|
68
68
|
'aria-required'?: boolean;
|
|
69
69
|
/** Whether the field can be automatically filled */
|
|
70
70
|
autoComplete?: string;
|
|
71
|
+
/** Whether the field should autofocus */
|
|
72
|
+
autoFocus?: boolean;
|
|
71
73
|
/** Additional classes to be added to the field */
|
|
72
74
|
className?: string;
|
|
73
75
|
/** The component to render, instead of rendering a field (e.g. for when we need a component like `EmailHelperTextBox` in the middle of a form). Please specify props when passing in. */
|
|
@@ -97,6 +99,10 @@ export interface IField {
|
|
|
97
99
|
onFocus?: () => void;
|
|
98
100
|
/** The function to call when a key is pressed */
|
|
99
101
|
onKeyInput?: <T>(arg1: FormValues) => Promise<T>;
|
|
102
|
+
/** The function to call when a key is pressed */
|
|
103
|
+
onKeyDown?: (e: React.KeyboardEvent<HTMLElement>) => void;
|
|
104
|
+
/** The function to call when the form is submitted from a field */
|
|
105
|
+
submitForm?: (arg: IFormValues) => void;
|
|
100
106
|
};
|
|
101
107
|
/** The Google Tag Manager data to be passed to the field */
|
|
102
108
|
gtm?: {
|
|
@@ -140,6 +146,8 @@ export interface IField {
|
|
|
140
146
|
required?: boolean;
|
|
141
147
|
/** The selected value for checkboxes */
|
|
142
148
|
shownValue?: InputValues;
|
|
149
|
+
/** Whether hitting enter on the field should submit the form */
|
|
150
|
+
submitOnEnter?: boolean;
|
|
143
151
|
/** The type of the input */
|
|
144
152
|
type?: InputTypes | 'checkboxes';
|
|
145
153
|
/** The validation for the field */
|
|
@@ -166,6 +174,8 @@ export interface IFormProps {
|
|
|
166
174
|
secondaryActionButton?: FormCancelButtonPropsType;
|
|
167
175
|
/** The classes to add to the form */
|
|
168
176
|
className?: string;
|
|
177
|
+
/** The type of element to render. This is in case we need to render a separate form inside the first, e.g. rendering the link form on the rich text editor inside the discussion form. */
|
|
178
|
+
element?: 'form' | 'fieldset';
|
|
169
179
|
/** The fields to render in the form */
|
|
170
180
|
fields: IField[];
|
|
171
181
|
/** An optional `ref` for the form, in case we need to interact with it in another file */
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Dispatch } from 'react';
|
|
2
|
+
import { Point } from 'slate';
|
|
3
|
+
declare const RichTextEditorContext: import("react").Context<{
|
|
4
|
+
/** The id of the editor */
|
|
5
|
+
id: string;
|
|
6
|
+
/** The toolbar option that is currently tabbable */
|
|
7
|
+
tabbableOption: string;
|
|
8
|
+
/** The function to set focus on the toolbar options */
|
|
9
|
+
setFocus: (option: string | null) => void;
|
|
10
|
+
/** The tooltip that is currently open */
|
|
11
|
+
openTooltip: string | null;
|
|
12
|
+
/** Whether the link editor is open */
|
|
13
|
+
showLinkEditor: boolean;
|
|
14
|
+
/** The last anchor point (used for Slate to know where the cursor is) */
|
|
15
|
+
lastAnchor: Point | null;
|
|
16
|
+
/** The function to update the state */
|
|
17
|
+
dispatch: Dispatch<any>;
|
|
18
|
+
}>;
|
|
19
|
+
export default RichTextEditorContext;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as RichTextEditorContext } from './context';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Element } from './element';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Leaf } from './leaf';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { BaseEditor } from 'slate';
|
|
2
|
+
export declare const isLinkActive: (editor: BaseEditor) => boolean;
|
|
3
|
+
export declare const insertLink: (editor: BaseEditor, url: string, id: string) => void;
|
|
4
|
+
export declare const wrapLink: (editor: BaseEditor, url: string, id: string) => void;
|
|
5
|
+
export declare const unwrapLink: (editor: BaseEditor) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as LinkOption } from './link-option';
|
|
@@ -0,0 +1,5 @@
|
|
|
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;
|
|
4
|
+
export declare const isMarkActive: (editor: BaseEditor, format: string) => boolean;
|
|
5
|
+
export declare const toggleMark: (editor: BaseEditor, format: string) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Option } from './option';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from 'react';
|
|
2
|
+
import { BaseProps } from '../../../../../../../form/components/rich-text-editor/rich-text-editor.types';
|
|
3
|
+
declare const Option: ({ id, active, hasDivider, callback, className, children, ...props }: React.PropsWithChildren<{
|
|
4
|
+
/** The id of the option */
|
|
5
|
+
id: string;
|
|
6
|
+
/** Whether the option is active */
|
|
7
|
+
active?: boolean | undefined;
|
|
8
|
+
/** Whether the option has a divider */
|
|
9
|
+
hasDivider?: boolean | undefined;
|
|
10
|
+
/** The callback to fire when the option is clicked */
|
|
11
|
+
callback: () => void;
|
|
12
|
+
/** Additional classes */
|
|
13
|
+
className?: string | undefined;
|
|
14
|
+
} & BaseProps>) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export default Option;
|
|
@@ -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,97 @@
|
|
|
1
|
+
export declare const html: {
|
|
2
|
+
paragraph: {
|
|
3
|
+
type: string;
|
|
4
|
+
children: {
|
|
5
|
+
text: string;
|
|
6
|
+
}[];
|
|
7
|
+
}[];
|
|
8
|
+
link: {
|
|
9
|
+
type: string;
|
|
10
|
+
children: ({
|
|
11
|
+
text: string;
|
|
12
|
+
type?: undefined;
|
|
13
|
+
link?: undefined;
|
|
14
|
+
children?: undefined;
|
|
15
|
+
} | {
|
|
16
|
+
type: string;
|
|
17
|
+
link: string;
|
|
18
|
+
children: {
|
|
19
|
+
text: string;
|
|
20
|
+
}[];
|
|
21
|
+
text?: undefined;
|
|
22
|
+
})[];
|
|
23
|
+
}[];
|
|
24
|
+
bold: {
|
|
25
|
+
type: string;
|
|
26
|
+
children: ({
|
|
27
|
+
text: string;
|
|
28
|
+
bold?: undefined;
|
|
29
|
+
} | {
|
|
30
|
+
bold: boolean;
|
|
31
|
+
text: string;
|
|
32
|
+
})[];
|
|
33
|
+
}[];
|
|
34
|
+
italic: {
|
|
35
|
+
type: string;
|
|
36
|
+
children: ({
|
|
37
|
+
text: string;
|
|
38
|
+
italic?: undefined;
|
|
39
|
+
} | {
|
|
40
|
+
italic: boolean;
|
|
41
|
+
text: string;
|
|
42
|
+
})[];
|
|
43
|
+
}[];
|
|
44
|
+
strikethrough: {
|
|
45
|
+
type: string;
|
|
46
|
+
children: ({
|
|
47
|
+
text: string;
|
|
48
|
+
strikeThrough?: undefined;
|
|
49
|
+
} | {
|
|
50
|
+
strikeThrough: boolean;
|
|
51
|
+
text: string;
|
|
52
|
+
})[];
|
|
53
|
+
}[];
|
|
54
|
+
blockquote: {
|
|
55
|
+
type: string;
|
|
56
|
+
children: {
|
|
57
|
+
type: string;
|
|
58
|
+
children: {
|
|
59
|
+
text: string;
|
|
60
|
+
}[];
|
|
61
|
+
}[];
|
|
62
|
+
}[];
|
|
63
|
+
ulList: {
|
|
64
|
+
type: string;
|
|
65
|
+
children: {
|
|
66
|
+
type: string;
|
|
67
|
+
children: {
|
|
68
|
+
type: string;
|
|
69
|
+
children: {
|
|
70
|
+
text: string;
|
|
71
|
+
}[];
|
|
72
|
+
}[];
|
|
73
|
+
}[];
|
|
74
|
+
}[];
|
|
75
|
+
olList: {
|
|
76
|
+
type: string;
|
|
77
|
+
children: {
|
|
78
|
+
type: string;
|
|
79
|
+
children: {
|
|
80
|
+
type: string;
|
|
81
|
+
children: {
|
|
82
|
+
text: string;
|
|
83
|
+
}[];
|
|
84
|
+
}[];
|
|
85
|
+
}[];
|
|
86
|
+
}[];
|
|
87
|
+
};
|
|
88
|
+
export declare const text: {
|
|
89
|
+
paragraph: string;
|
|
90
|
+
link: string;
|
|
91
|
+
bold: string;
|
|
92
|
+
italic: string;
|
|
93
|
+
strikethrough: string;
|
|
94
|
+
blockquote: string;
|
|
95
|
+
ulList: string;
|
|
96
|
+
olList: string;
|
|
97
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as HOTKEYS } from './hot-keys';
|