@soul-refiner/design-system 0.1.25 → 0.1.27
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/package.json +7 -6
- package/src/components/actions/dropdown/dropdown.tsx +14 -11
- package/src/components/atoms/typography/typography.tsx +1 -1
- package/src/components/editor/constants.ts +181 -0
- package/src/components/editor/editor.tsx +95 -0
- package/src/components/editor/index.ts +2 -0
- package/src/components/editor/navbar/alignment_dropdown.tsx +142 -0
- package/src/components/editor/navbar/button_modal.tsx +146 -0
- package/src/components/editor/navbar/index.ts +2 -0
- package/src/components/editor/navbar/navbar.tsx +350 -0
- package/src/components/editor/navbar/style_dropdown.tsx +107 -0
- package/src/components/editor/plate.ts +37 -0
- package/src/components/editor/plugins/blockquote.tsx +25 -0
- package/src/components/editor/plugins/buttons.tsx +140 -0
- package/src/components/editor/plugins/exitBreak.ts +39 -0
- package/src/components/editor/plugins/image.tsx +80 -0
- package/src/components/editor/plugins/index.ts +165 -0
- package/src/components/editor/plugins/link.tsx +144 -0
- package/src/components/editor/plugins/list.tsx +34 -0
- package/src/components/editor/plugins/resetBlockType.ts +29 -0
- package/src/components/editor/plugins/selectOnBackspace.ts +7 -0
- package/src/components/editor/plugins/softBreak.ts +19 -0
- package/src/components/editor/plugins/text.tsx +142 -0
- package/src/components/index.ts +1 -0
- package/src/components/input/radio/radio.tsx +2 -2
- package/src/components/surfaces/modal/modal.tsx +6 -2
- package/src/icons/text/align_justified.tsx +1 -1
- package/tsconfig.json +1 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import {
|
|
4
|
+
Box,
|
|
5
|
+
Caption,
|
|
6
|
+
CaptionTextarea,
|
|
7
|
+
Image,
|
|
8
|
+
PlateElement,
|
|
9
|
+
PlateElementProps,
|
|
10
|
+
Resizable,
|
|
11
|
+
TImageElement,
|
|
12
|
+
useMediaState,
|
|
13
|
+
Value,
|
|
14
|
+
} from '@udecode/plate';
|
|
15
|
+
import { useReadOnly } from 'slate-react';
|
|
16
|
+
|
|
17
|
+
const align = 'center';
|
|
18
|
+
|
|
19
|
+
export const ImageElement = ({
|
|
20
|
+
...props
|
|
21
|
+
}: PlateElementProps<Value, TImageElement>) => {
|
|
22
|
+
const { children, nodeProps } = props;
|
|
23
|
+
|
|
24
|
+
const readOnly = useReadOnly();
|
|
25
|
+
|
|
26
|
+
useMediaState();
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<PlateElement {...props}>
|
|
30
|
+
<Figure className="group" contentEditable={false}>
|
|
31
|
+
<Resizable
|
|
32
|
+
style={{
|
|
33
|
+
alignItems: 'center',
|
|
34
|
+
width: '100%',
|
|
35
|
+
maxWidth: '100%',
|
|
36
|
+
marginLeft: 'auto',
|
|
37
|
+
marginRight: 'auto',
|
|
38
|
+
}}
|
|
39
|
+
options={{
|
|
40
|
+
renderHandleLeft: (htmlProps) => <Box {...htmlProps} />,
|
|
41
|
+
renderHandleRight: (htmlProps) => <Box {...htmlProps} />,
|
|
42
|
+
align,
|
|
43
|
+
readOnly,
|
|
44
|
+
}}
|
|
45
|
+
>
|
|
46
|
+
<Image {...nodeProps} />
|
|
47
|
+
</Resizable>
|
|
48
|
+
<Caption className="HERE">
|
|
49
|
+
<Textarea
|
|
50
|
+
$readOnly={readOnly}
|
|
51
|
+
placeholder="Write a caption..."
|
|
52
|
+
readOnly={readOnly}
|
|
53
|
+
/>
|
|
54
|
+
</Caption>
|
|
55
|
+
</Figure>
|
|
56
|
+
{children}
|
|
57
|
+
</PlateElement>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const Figure = styled.figure`
|
|
62
|
+
position: relative;
|
|
63
|
+
margin: 0px;
|
|
64
|
+
width: 100%;
|
|
65
|
+
|
|
66
|
+
img {
|
|
67
|
+
width: 100%;
|
|
68
|
+
}
|
|
69
|
+
`;
|
|
70
|
+
|
|
71
|
+
const Textarea = styled(CaptionTextarea)<{ $readOnly: boolean }>`
|
|
72
|
+
width: 100%;
|
|
73
|
+
padding: 8px 16px;
|
|
74
|
+
box-sizing: border-box;
|
|
75
|
+
text-align: center;
|
|
76
|
+
resize: none;
|
|
77
|
+
outline: none;
|
|
78
|
+
border: 1px solid
|
|
79
|
+
${({ $readOnly }) => ($readOnly ? 'transparent' : 'var(--color-grey-9)')};
|
|
80
|
+
`;
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PLUGINS
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
createBlockquotePlugin,
|
|
6
|
+
createCodeBlockPlugin,
|
|
7
|
+
createHeadingPlugin,
|
|
8
|
+
createHorizontalRulePlugin,
|
|
9
|
+
createIndentListPlugin,
|
|
10
|
+
createImagePlugin,
|
|
11
|
+
createTextIndentPlugin,
|
|
12
|
+
createListPlugin,
|
|
13
|
+
createMediaEmbedPlugin,
|
|
14
|
+
createResetNodePlugin,
|
|
15
|
+
createTablePlugin,
|
|
16
|
+
createBoldPlugin,
|
|
17
|
+
createCodePlugin,
|
|
18
|
+
createFontBackgroundColorPlugin,
|
|
19
|
+
createFontSizePlugin,
|
|
20
|
+
createFontFamilyPlugin,
|
|
21
|
+
createItalicPlugin,
|
|
22
|
+
createStrikethroughPlugin,
|
|
23
|
+
createSubscriptPlugin,
|
|
24
|
+
createSuperscriptPlugin,
|
|
25
|
+
createUnderlinePlugin,
|
|
26
|
+
createAlignPlugin,
|
|
27
|
+
createIndentPlugin,
|
|
28
|
+
createLineHeightPlugin,
|
|
29
|
+
createLinkPlugin,
|
|
30
|
+
createExitBreakPlugin,
|
|
31
|
+
createHistoryPlugin,
|
|
32
|
+
createSelectOnBackspacePlugin,
|
|
33
|
+
createSoftBreakPlugin,
|
|
34
|
+
} from '@udecode/plate';
|
|
35
|
+
import { createButtonsPlugin } from './buttons';
|
|
36
|
+
import { exitBreakPlugin } from './exitBreak';
|
|
37
|
+
import { resetBlockTypePlugin } from './resetBlockType';
|
|
38
|
+
import { selectOnBackspace } from './selectOnBackspace';
|
|
39
|
+
import { softBreakPlugin } from './softBreak';
|
|
40
|
+
import {
|
|
41
|
+
createParagraphPlugin,
|
|
42
|
+
createHOnePlugin,
|
|
43
|
+
createHTwoPlugin,
|
|
44
|
+
createHThreePlugin,
|
|
45
|
+
createHFourPlugin,
|
|
46
|
+
createHFivePlugin,
|
|
47
|
+
createHSixPlugin,
|
|
48
|
+
} from './text';
|
|
49
|
+
|
|
50
|
+
import { LinkFloatingMenu } from './link';
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* ELEMENT TYPES
|
|
54
|
+
*/
|
|
55
|
+
import {
|
|
56
|
+
ELEMENT_PARAGRAPH,
|
|
57
|
+
ELEMENT_H1,
|
|
58
|
+
ELEMENT_H2,
|
|
59
|
+
ELEMENT_H3,
|
|
60
|
+
ELEMENT_H4,
|
|
61
|
+
ELEMENT_H5,
|
|
62
|
+
ELEMENT_H6,
|
|
63
|
+
ELEMENT_OL,
|
|
64
|
+
ELEMENT_UL,
|
|
65
|
+
} from '../constants';
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* ELEMENT TYPES
|
|
69
|
+
*/
|
|
70
|
+
export const blocks = [
|
|
71
|
+
createButtonsPlugin(),
|
|
72
|
+
createBlockquotePlugin(),
|
|
73
|
+
createCodeBlockPlugin(),
|
|
74
|
+
createHeadingPlugin(),
|
|
75
|
+
createHorizontalRulePlugin(),
|
|
76
|
+
createImagePlugin({
|
|
77
|
+
options: {
|
|
78
|
+
disableUploadInsert: true,
|
|
79
|
+
disableCaption: true,
|
|
80
|
+
disableEmbedInsert: true,
|
|
81
|
+
},
|
|
82
|
+
}),
|
|
83
|
+
createTextIndentPlugin(),
|
|
84
|
+
createIndentListPlugin({
|
|
85
|
+
inject: {
|
|
86
|
+
props: {
|
|
87
|
+
validTypes: [
|
|
88
|
+
ELEMENT_PARAGRAPH,
|
|
89
|
+
ELEMENT_H1,
|
|
90
|
+
ELEMENT_H2,
|
|
91
|
+
ELEMENT_H3,
|
|
92
|
+
ELEMENT_H4,
|
|
93
|
+
ELEMENT_H5,
|
|
94
|
+
ELEMENT_H6,
|
|
95
|
+
ELEMENT_OL,
|
|
96
|
+
ELEMENT_UL,
|
|
97
|
+
],
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
}),
|
|
101
|
+
createListPlugin(),
|
|
102
|
+
createMediaEmbedPlugin(),
|
|
103
|
+
createParagraphPlugin(),
|
|
104
|
+
createHOnePlugin(),
|
|
105
|
+
createHTwoPlugin(),
|
|
106
|
+
createHThreePlugin(),
|
|
107
|
+
createHFourPlugin(),
|
|
108
|
+
createHFivePlugin(),
|
|
109
|
+
createHSixPlugin(),
|
|
110
|
+
// createPaywallPlugin(),
|
|
111
|
+
// createQAPlugin(),
|
|
112
|
+
createResetNodePlugin(),
|
|
113
|
+
createTablePlugin(),
|
|
114
|
+
// createVideoPlugin(),
|
|
115
|
+
];
|
|
116
|
+
|
|
117
|
+
export const marks = [
|
|
118
|
+
createBoldPlugin(),
|
|
119
|
+
createCodePlugin(),
|
|
120
|
+
createFontBackgroundColorPlugin(),
|
|
121
|
+
createFontSizePlugin(),
|
|
122
|
+
createFontFamilyPlugin(),
|
|
123
|
+
createItalicPlugin(),
|
|
124
|
+
createStrikethroughPlugin(),
|
|
125
|
+
createSubscriptPlugin(),
|
|
126
|
+
createSuperscriptPlugin(),
|
|
127
|
+
createUnderlinePlugin(),
|
|
128
|
+
];
|
|
129
|
+
|
|
130
|
+
export const inline = [
|
|
131
|
+
createAlignPlugin({
|
|
132
|
+
inject: {
|
|
133
|
+
props: {
|
|
134
|
+
validTypes: [
|
|
135
|
+
ELEMENT_PARAGRAPH,
|
|
136
|
+
ELEMENT_H1,
|
|
137
|
+
ELEMENT_H2,
|
|
138
|
+
ELEMENT_H3,
|
|
139
|
+
ELEMENT_H4,
|
|
140
|
+
ELEMENT_H5,
|
|
141
|
+
ELEMENT_H6,
|
|
142
|
+
],
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
}),
|
|
146
|
+
createIndentPlugin({
|
|
147
|
+
inject: {
|
|
148
|
+
props: {
|
|
149
|
+
validTypes: [ELEMENT_PARAGRAPH, ELEMENT_H1],
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
}),
|
|
153
|
+
createLineHeightPlugin(),
|
|
154
|
+
createLinkPlugin({
|
|
155
|
+
renderAfterEditable: LinkFloatingMenu,
|
|
156
|
+
}),
|
|
157
|
+
];
|
|
158
|
+
|
|
159
|
+
export const utils = [
|
|
160
|
+
createExitBreakPlugin(exitBreakPlugin),
|
|
161
|
+
createHistoryPlugin(),
|
|
162
|
+
createResetNodePlugin(resetBlockTypePlugin),
|
|
163
|
+
createSelectOnBackspacePlugin(selectOnBackspace),
|
|
164
|
+
createSoftBreakPlugin(softBreakPlugin),
|
|
165
|
+
];
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import {
|
|
4
|
+
FloatingLinkUrlInput,
|
|
5
|
+
LinkOpenButton,
|
|
6
|
+
PlateElement,
|
|
7
|
+
PlateElementProps,
|
|
8
|
+
TEditableProps,
|
|
9
|
+
TLinkElement,
|
|
10
|
+
useFloatingLinkEdit,
|
|
11
|
+
useFloatingLinkEditState,
|
|
12
|
+
useFloatingLinkInsert,
|
|
13
|
+
useFloatingLinkInsertState,
|
|
14
|
+
useFloatingLinkSelectors,
|
|
15
|
+
useLink,
|
|
16
|
+
Value,
|
|
17
|
+
} from '@udecode/plate';
|
|
18
|
+
import { Box } from 'components';
|
|
19
|
+
import { AASansSerif, Link, Upload } from 'icons';
|
|
20
|
+
|
|
21
|
+
export const LinkElement = React.forwardRef<
|
|
22
|
+
React.ElementRef<typeof PlateElement>,
|
|
23
|
+
PlateElementProps<Value, TLinkElement>
|
|
24
|
+
>(({ children, ...props }, ref) => {
|
|
25
|
+
const { props: linkProps } = useLink({ element: props.element });
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<PlateElement asChild ref={ref} {...linkProps} {...(props as any)}>
|
|
29
|
+
<a>{children}</a>
|
|
30
|
+
</PlateElement>
|
|
31
|
+
);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export const LinkFloatingMenu = ({ readOnly }: TEditableProps) => {
|
|
35
|
+
const isEditing = useFloatingLinkSelectors().isEditing();
|
|
36
|
+
|
|
37
|
+
const state = useFloatingLinkInsertState();
|
|
38
|
+
const {
|
|
39
|
+
props: insertProps,
|
|
40
|
+
ref: insertRef,
|
|
41
|
+
textInputProps,
|
|
42
|
+
} = useFloatingLinkInsert(state);
|
|
43
|
+
|
|
44
|
+
const editState = useFloatingLinkEditState();
|
|
45
|
+
const {
|
|
46
|
+
props: editProps,
|
|
47
|
+
ref: editRef,
|
|
48
|
+
editButtonProps,
|
|
49
|
+
} = useFloatingLinkEdit(editState);
|
|
50
|
+
|
|
51
|
+
if (readOnly) return null;
|
|
52
|
+
|
|
53
|
+
const input = (
|
|
54
|
+
<Box
|
|
55
|
+
$dir="column"
|
|
56
|
+
sx={`
|
|
57
|
+
background-color: var(--color-white);
|
|
58
|
+
gap: 16px;
|
|
59
|
+
padding: 16px;
|
|
60
|
+
border-radius: 16px;
|
|
61
|
+
box-shadow: var(--elevation-2);
|
|
62
|
+
`}
|
|
63
|
+
>
|
|
64
|
+
<Box $align="center" $justify="center" $gap={8}>
|
|
65
|
+
<Box $align="center" $justify="center">
|
|
66
|
+
<Link />
|
|
67
|
+
</Box>
|
|
68
|
+
<FloatingLinkUrlInput
|
|
69
|
+
style={{
|
|
70
|
+
border: 'none',
|
|
71
|
+
outline: 'none',
|
|
72
|
+
padding: '8px 12px',
|
|
73
|
+
}}
|
|
74
|
+
placeholder="Paste link"
|
|
75
|
+
/>
|
|
76
|
+
</Box>
|
|
77
|
+
<Box $align="center" $justify="center" $gap={8}>
|
|
78
|
+
<Box $align="center" $justify="center">
|
|
79
|
+
<AASansSerif />
|
|
80
|
+
</Box>
|
|
81
|
+
<Input placeholder="Text to display" {...textInputProps} />
|
|
82
|
+
</Box>
|
|
83
|
+
</Box>
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
const editContent = isEditing ? (
|
|
87
|
+
input
|
|
88
|
+
) : (
|
|
89
|
+
<Box
|
|
90
|
+
$align="center"
|
|
91
|
+
$justify="center"
|
|
92
|
+
sx={`
|
|
93
|
+
box-sizing: box-content;
|
|
94
|
+
background-color: var(--color-white);
|
|
95
|
+
gap: 8px;
|
|
96
|
+
padding: 16px;
|
|
97
|
+
border-radius: 16px;
|
|
98
|
+
box-shadow: var(--elevation-2);
|
|
99
|
+
|
|
100
|
+
a,
|
|
101
|
+
button {
|
|
102
|
+
padding: 8px 12px;
|
|
103
|
+
background-color: transparent;
|
|
104
|
+
outline: none;
|
|
105
|
+
border: none;
|
|
106
|
+
border-radius: 8px;
|
|
107
|
+
cursor: pointer;
|
|
108
|
+
width: max-content;
|
|
109
|
+
font-size: 16px;
|
|
110
|
+
line-height: 16px;
|
|
111
|
+
|
|
112
|
+
&:hover {
|
|
113
|
+
background-color: var(--color-grey-9);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
`}
|
|
117
|
+
$gap={8}
|
|
118
|
+
>
|
|
119
|
+
<button type="button" {...editButtonProps}>
|
|
120
|
+
Edit link
|
|
121
|
+
</button>
|
|
122
|
+
<LinkOpenButton>
|
|
123
|
+
<Upload />
|
|
124
|
+
</LinkOpenButton>
|
|
125
|
+
</Box>
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
return (
|
|
129
|
+
<>
|
|
130
|
+
<div ref={insertRef} {...insertProps}>
|
|
131
|
+
{input}
|
|
132
|
+
</div>
|
|
133
|
+
<div ref={editRef} {...editProps}>
|
|
134
|
+
{editContent}
|
|
135
|
+
</div>
|
|
136
|
+
</>
|
|
137
|
+
);
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const Input = styled.input`
|
|
141
|
+
border: none;
|
|
142
|
+
outline: none;
|
|
143
|
+
padding: 8px 12px;
|
|
144
|
+
`;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { PlateElement, PlateElementProps } from '@udecode/plate';
|
|
3
|
+
import { styled } from 'styled-components';
|
|
4
|
+
|
|
5
|
+
export const ListElement = ({
|
|
6
|
+
children,
|
|
7
|
+
variant = 'ul',
|
|
8
|
+
...props
|
|
9
|
+
}: PlateElementProps & {
|
|
10
|
+
variant: 'ul' | 'ol';
|
|
11
|
+
}) => {
|
|
12
|
+
const Element = variant;
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<PlateElement asChild {...props}>
|
|
16
|
+
<>
|
|
17
|
+
<Element>
|
|
18
|
+
{React.Children.map(children, (child) => (
|
|
19
|
+
<Li>{child}</Li>
|
|
20
|
+
))}
|
|
21
|
+
</Element>
|
|
22
|
+
</>
|
|
23
|
+
</PlateElement>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const Li = styled.li`
|
|
28
|
+
margin: 16px 0px;
|
|
29
|
+
padding-left: 8px;
|
|
30
|
+
|
|
31
|
+
&::marker {
|
|
32
|
+
color: var(--color-grey-4);
|
|
33
|
+
}
|
|
34
|
+
`;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { isBlockAboveEmpty, isSelectionAtBlockStart } from '@udecode/plate';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
ELEMENT_BLOCKQUOTE,
|
|
5
|
+
ELEMENT_PARAGRAPH,
|
|
6
|
+
ELEMENT_TODO_LI,
|
|
7
|
+
} from '../constants';
|
|
8
|
+
|
|
9
|
+
const resetBlockTypesCommonRule = {
|
|
10
|
+
types: [ELEMENT_BLOCKQUOTE, ELEMENT_TODO_LI],
|
|
11
|
+
defaultType: ELEMENT_PARAGRAPH,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const resetBlockTypePlugin = {
|
|
15
|
+
options: {
|
|
16
|
+
rules: [
|
|
17
|
+
{
|
|
18
|
+
...resetBlockTypesCommonRule,
|
|
19
|
+
hotkey: 'Enter',
|
|
20
|
+
predicate: isBlockAboveEmpty,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
...resetBlockTypesCommonRule,
|
|
24
|
+
hotkey: 'Backspace',
|
|
25
|
+
predicate: isSelectionAtBlockStart,
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ELEMENT_BLOCKQUOTE,
|
|
3
|
+
ELEMENT_CODE_BLOCK,
|
|
4
|
+
ELEMENT_TD,
|
|
5
|
+
} from '@udecode/plate';
|
|
6
|
+
|
|
7
|
+
export const softBreakPlugin = {
|
|
8
|
+
options: {
|
|
9
|
+
rules: [
|
|
10
|
+
{ hotkey: 'shift+enter' },
|
|
11
|
+
{
|
|
12
|
+
hotkey: 'enter',
|
|
13
|
+
query: {
|
|
14
|
+
allow: [ELEMENT_CODE_BLOCK, ELEMENT_BLOCKQUOTE, ELEMENT_TD],
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
},
|
|
19
|
+
};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
createPluginFactory,
|
|
4
|
+
PlateElement,
|
|
5
|
+
PlateElementProps,
|
|
6
|
+
PlateRenderElementProps,
|
|
7
|
+
} from '@udecode/plate';
|
|
8
|
+
import { H, P } from 'components';
|
|
9
|
+
import * as Elements from '../constants';
|
|
10
|
+
|
|
11
|
+
export const ParagraphElement = React.forwardRef<
|
|
12
|
+
React.ElementRef<typeof PlateElement>,
|
|
13
|
+
PlateElementProps
|
|
14
|
+
>(({ children, ...props }: PlateRenderElementProps, ref) => {
|
|
15
|
+
return (
|
|
16
|
+
<PlateElement asChild ref={ref} {...props}>
|
|
17
|
+
<>
|
|
18
|
+
<P as="div">{children}</P>
|
|
19
|
+
</>
|
|
20
|
+
</PlateElement>
|
|
21
|
+
);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export const createParagraphPlugin = createPluginFactory({
|
|
25
|
+
key: Elements.ELEMENT_PARAGRAPH,
|
|
26
|
+
type: Elements.ELEMENT_PARAGRAPH,
|
|
27
|
+
isElement: true,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export const HOneElement = React.forwardRef<
|
|
31
|
+
React.ElementRef<typeof PlateElement>,
|
|
32
|
+
PlateElementProps
|
|
33
|
+
>(({ children, ...props }: PlateRenderElementProps, ref) => {
|
|
34
|
+
return (
|
|
35
|
+
<PlateElement asChild ref={ref} {...props}>
|
|
36
|
+
<>
|
|
37
|
+
<H.One>{children}</H.One>
|
|
38
|
+
</>
|
|
39
|
+
</PlateElement>
|
|
40
|
+
);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export const createHOnePlugin = createPluginFactory({
|
|
44
|
+
key: Elements.ELEMENT_H1,
|
|
45
|
+
type: Elements.ELEMENT_H1,
|
|
46
|
+
isElement: true,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
export const HTwoElement = React.forwardRef<
|
|
50
|
+
React.ElementRef<typeof PlateElement>,
|
|
51
|
+
PlateElementProps
|
|
52
|
+
>(({ children, ...props }: PlateRenderElementProps, ref) => {
|
|
53
|
+
return (
|
|
54
|
+
<PlateElement asChild ref={ref} {...props}>
|
|
55
|
+
<>
|
|
56
|
+
<H.Two>{children}</H.Two>
|
|
57
|
+
</>
|
|
58
|
+
</PlateElement>
|
|
59
|
+
);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
export const createHTwoPlugin = createPluginFactory({
|
|
63
|
+
key: Elements.ELEMENT_H2,
|
|
64
|
+
type: Elements.ELEMENT_H2,
|
|
65
|
+
isElement: true,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
export const HThreeElement = React.forwardRef<
|
|
69
|
+
React.ElementRef<typeof PlateElement>,
|
|
70
|
+
PlateElementProps
|
|
71
|
+
>(({ children, ...props }: PlateRenderElementProps, ref) => {
|
|
72
|
+
return (
|
|
73
|
+
<PlateElement asChild ref={ref} {...props}>
|
|
74
|
+
<>
|
|
75
|
+
<H.Three>{children}</H.Three>
|
|
76
|
+
</>
|
|
77
|
+
</PlateElement>
|
|
78
|
+
);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
export const createHThreePlugin = createPluginFactory({
|
|
82
|
+
key: Elements.ELEMENT_H3,
|
|
83
|
+
type: Elements.ELEMENT_H3,
|
|
84
|
+
isElement: true,
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
export const HFourElement = React.forwardRef<
|
|
88
|
+
React.ElementRef<typeof PlateElement>,
|
|
89
|
+
PlateElementProps
|
|
90
|
+
>(({ children, ...props }: PlateRenderElementProps, ref) => {
|
|
91
|
+
return (
|
|
92
|
+
<PlateElement asChild ref={ref} {...props}>
|
|
93
|
+
<>
|
|
94
|
+
<H.Four>{children}</H.Four>
|
|
95
|
+
</>
|
|
96
|
+
</PlateElement>
|
|
97
|
+
);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
export const createHFourPlugin = createPluginFactory({
|
|
101
|
+
key: Elements.ELEMENT_H4,
|
|
102
|
+
type: Elements.ELEMENT_H4,
|
|
103
|
+
isElement: true,
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
export const HFiveElement = React.forwardRef<
|
|
107
|
+
React.ElementRef<typeof PlateElement>,
|
|
108
|
+
PlateElementProps
|
|
109
|
+
>(({ children, ...props }: PlateRenderElementProps, ref) => {
|
|
110
|
+
return (
|
|
111
|
+
<PlateElement asChild ref={ref} {...props}>
|
|
112
|
+
<>
|
|
113
|
+
<H.Five>{children}</H.Five>
|
|
114
|
+
</>
|
|
115
|
+
</PlateElement>
|
|
116
|
+
);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
export const createHFivePlugin = createPluginFactory({
|
|
120
|
+
key: Elements.ELEMENT_H5,
|
|
121
|
+
type: Elements.ELEMENT_H5,
|
|
122
|
+
isElement: true,
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
export const HSixElement = React.forwardRef<
|
|
126
|
+
React.ElementRef<typeof PlateElement>,
|
|
127
|
+
PlateElementProps
|
|
128
|
+
>(({ children, ...props }: PlateRenderElementProps, ref) => {
|
|
129
|
+
return (
|
|
130
|
+
<PlateElement asChild ref={ref} {...props}>
|
|
131
|
+
<>
|
|
132
|
+
<H.Six>{children}</H.Six>
|
|
133
|
+
</>
|
|
134
|
+
</PlateElement>
|
|
135
|
+
);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
export const createHSixPlugin = createPluginFactory({
|
|
139
|
+
key: Elements.ELEMENT_H6,
|
|
140
|
+
type: Elements.ELEMENT_H6,
|
|
141
|
+
isElement: true,
|
|
142
|
+
});
|
package/src/components/index.ts
CHANGED
|
@@ -18,7 +18,7 @@ export interface RadioProps extends NativeProps {
|
|
|
18
18
|
checked: boolean;
|
|
19
19
|
disabled?: boolean;
|
|
20
20
|
label?: string;
|
|
21
|
-
onChange
|
|
21
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
22
22
|
name?: string;
|
|
23
23
|
reversed?: boolean;
|
|
24
24
|
sx?: string;
|
|
@@ -37,7 +37,7 @@ const Radio = ({
|
|
|
37
37
|
}: RadioProps) => {
|
|
38
38
|
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
39
39
|
event.stopPropagation();
|
|
40
|
-
onChange(event);
|
|
40
|
+
onChange && onChange(event);
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
return (
|
|
@@ -47,6 +47,7 @@ Modal.Trigger = ModalTrigger;
|
|
|
47
47
|
|
|
48
48
|
const ModalDismiss = ({
|
|
49
49
|
children: child,
|
|
50
|
+
|
|
50
51
|
setClosed,
|
|
51
52
|
}: {
|
|
52
53
|
children: React.ReactElement;
|
|
@@ -73,6 +74,7 @@ export interface ModalContentProps extends React.PropsWithChildren {
|
|
|
73
74
|
footer?: React.ReactElement;
|
|
74
75
|
header?: React.ReactElement;
|
|
75
76
|
setClosed?: () => void;
|
|
77
|
+
sx?: string;
|
|
76
78
|
}
|
|
77
79
|
|
|
78
80
|
const ModalContent = ({
|
|
@@ -81,6 +83,7 @@ const ModalContent = ({
|
|
|
81
83
|
footer,
|
|
82
84
|
header,
|
|
83
85
|
setClosed,
|
|
86
|
+
sx,
|
|
84
87
|
...props
|
|
85
88
|
}: ModalContentProps) => {
|
|
86
89
|
const [open, setOpen] = React.useContext(ModalContext);
|
|
@@ -96,7 +99,7 @@ const ModalContent = ({
|
|
|
96
99
|
$open={open}
|
|
97
100
|
onClick={handleOutsideClick}
|
|
98
101
|
>
|
|
99
|
-
<Content {...props}>
|
|
102
|
+
<Content {...props} $sx={sx}>
|
|
100
103
|
{header && (
|
|
101
104
|
<div className="header">
|
|
102
105
|
<div>{header}</div>
|
|
@@ -144,7 +147,7 @@ const Wrapper = styled.div<{
|
|
|
144
147
|
overflow: hidden;
|
|
145
148
|
`;
|
|
146
149
|
|
|
147
|
-
const Content = styled.div
|
|
150
|
+
const Content = styled.div<{ $sx?: string }>`
|
|
148
151
|
position: absolute;
|
|
149
152
|
z-index: 101;
|
|
150
153
|
background-color: var(--color-white);
|
|
@@ -169,4 +172,5 @@ const Content = styled.div`
|
|
|
169
172
|
position: relative;
|
|
170
173
|
padding-top: 16px;
|
|
171
174
|
}
|
|
175
|
+
${({ $sx }) => ($sx ? $sx : '')}
|
|
172
176
|
`;
|
|
@@ -7,7 +7,7 @@ export const AlignJustified = (props: IconProps) => {
|
|
|
7
7
|
<path
|
|
8
8
|
fillRule="evenodd"
|
|
9
9
|
clipRule="evenodd"
|
|
10
|
-
d="M14.6673 4.66671V3.33337H1.33398V4.66671H14.
|
|
10
|
+
d="M14.6673 4.66671V3.33337H1.33398V4.66671H14.6673ZM14.6673 6.00004V7.33337H1.33398V6.00004H14.6673ZM14.6673 10V8.66671H1.33398V10H14.6673ZM14.6673 12.6667V11.3334H1.33398V12.6667H14.6673Z"
|
|
11
11
|
/>
|
|
12
12
|
</Icon>
|
|
13
13
|
);
|