@soul-refiner/design-system 1.2.1 → 1.3.2
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/dist/components/atoms/hide/hide.d.ts +7 -0
- package/dist/components/atoms/hide/hide.js +9 -0
- package/dist/components/atoms/hide/index.d.ts +1 -0
- package/dist/components/atoms/hide/index.js +1 -0
- package/dist/components/atoms/index.d.ts +1 -0
- package/dist/components/atoms/index.js +1 -0
- package/dist/components/editor/constants.d.ts +9 -6
- package/dist/components/editor/constants.js +10 -7
- package/dist/components/editor/context.d.ts +1 -0
- package/dist/components/editor/context.js +1 -0
- package/dist/components/editor/editor.d.ts +3 -2
- package/dist/components/editor/editor.js +6 -2
- package/dist/components/editor/navbar/navbar.d.ts +1 -1
- package/dist/components/editor/navbar/navbar.js +1 -1
- package/dist/components/editor/plugins/index.js +2 -0
- package/dist/components/editor/plugins/qa.js +6 -3
- package/dist/components/editor/plugins/video.d.ts +4 -0
- package/dist/components/editor/plugins/video.js +40 -0
- package/package.json +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface HideButRenderProps extends React.PropsWithChildren {
|
|
3
|
+
displaceContent?: boolean;
|
|
4
|
+
show?: boolean;
|
|
5
|
+
styles?: React.CSSProperties;
|
|
6
|
+
}
|
|
7
|
+
export declare const HideButRender: ({ children, displaceContent, show, styles, }: HideButRenderProps) => React.JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export const HideButRender = ({ children, displaceContent = false, show = false, styles, }) => {
|
|
3
|
+
return (React.createElement("div", { style: {
|
|
4
|
+
visibility: show ? 'visible' : 'hidden',
|
|
5
|
+
position: displaceContent || show ? 'initial' : 'absolute',
|
|
6
|
+
zIndex: -100,
|
|
7
|
+
...styles,
|
|
8
|
+
} }, children));
|
|
9
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { HideButRender } from './hide';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { HideButRender } from './hide';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { Box } from './box';
|
|
2
2
|
export type { BoxProps } from './box';
|
|
3
|
+
export { HideButRender } from './hide';
|
|
3
4
|
export { SecToDuration } from './seconds_to_duration';
|
|
4
5
|
export type { SecondsToDurationProps } from './seconds_to_duration';
|
|
5
6
|
export { Display, H, P, Typography } from './typography';
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
export { ELEMENT_BLOCKQUOTE, ELEMENT_CODE_LINE, ELEMENT_CODE_SYNTAX, ELEMENT_DEFAULT, ELEMENT_H1, ELEMENT_H2, ELEMENT_H3, ELEMENT_H4, ELEMENT_H5, ELEMENT_H6, ELEMENT_HR, ELEMENT_IMAGE, ELEMENT_LI, ELEMENT_LIC, ELEMENT_LINK, ELEMENT_MEDIA, ELEMENT_MEDIA_EMBED, ELEMENT_MENTION, ELEMENT_MENTION_INPUT, ELEMENT_OL, ELEMENT_PARAGRAPH, ELEMENT_TABLE, ELEMENT_TD, ELEMENT_TH, ELEMENT_TODO_LI, ELEMENT_TR, ELEMENT_UL, MARK_BG_COLOR, MARK_BOLD, MARK_CODE, MARK_COLOR, MARK_FONT_FAMILY, MARK_FONT_SIZE, MARK_FONT_WEIGHT, MARK_HIGHLIGHT, MARK_ITALIC, MARK_KBD, MARK_SEARCH_HIGHLIGHT, MARK_STRIKETHROUGH, MARK_SUBSCRIPT, MARK_SUPERSCRIPT, MARK_UNDERLINE, } from '@udecode/plate';
|
|
2
|
-
export declare const ELEMENT_AUDIO = "audio";
|
|
3
|
-
export declare const ELEMENT_BIBLE_QUOTE = "bible-quote";
|
|
4
2
|
export declare const ELEMENT_BUTTON = "button";
|
|
5
|
-
export declare const ELEMENT_EXAMPLE = "example";
|
|
6
|
-
export declare const ELEMENT_FOOTNOTE = "footnote";
|
|
7
3
|
export declare const ELEMENT_PAYWALL = "paywall";
|
|
8
|
-
export declare const ELEMENT_POLL = "poll";
|
|
9
4
|
export declare const ELEMENT_QA = "q-n-a";
|
|
10
|
-
export declare const ELEMENT_RECIPE = "recipe";
|
|
11
5
|
export declare const ELEMENT_VIDEO = "video";
|
|
12
6
|
export declare const BUTTON_LINK = "button-link";
|
|
13
7
|
export declare const BUTTON_SUBSCRIBE = "button-subscribe";
|
|
@@ -19,10 +13,19 @@ export declare const DEFAULT_CONTENT: ({
|
|
|
19
13
|
}[];
|
|
20
14
|
questionAnswerId: string;
|
|
21
15
|
type: string;
|
|
16
|
+
thumbnail?: undefined;
|
|
22
17
|
} | {
|
|
23
18
|
children: {
|
|
24
19
|
text: string;
|
|
25
20
|
}[];
|
|
21
|
+
thumbnail: string;
|
|
26
22
|
type: string;
|
|
27
23
|
questionAnswerId?: undefined;
|
|
24
|
+
} | {
|
|
25
|
+
children: {
|
|
26
|
+
text: string;
|
|
27
|
+
}[];
|
|
28
|
+
type: string;
|
|
29
|
+
questionAnswerId?: undefined;
|
|
30
|
+
thumbnail?: undefined;
|
|
28
31
|
})[];
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
export { ELEMENT_BLOCKQUOTE, ELEMENT_CODE_LINE, ELEMENT_CODE_SYNTAX, ELEMENT_DEFAULT, ELEMENT_H1, ELEMENT_H2, ELEMENT_H3, ELEMENT_H4, ELEMENT_H5, ELEMENT_H6, ELEMENT_HR, ELEMENT_IMAGE, ELEMENT_LI, ELEMENT_LIC, ELEMENT_LINK, ELEMENT_MEDIA, ELEMENT_MEDIA_EMBED, ELEMENT_MENTION, ELEMENT_MENTION_INPUT, ELEMENT_OL, ELEMENT_PARAGRAPH, ELEMENT_TABLE, ELEMENT_TD, ELEMENT_TH, ELEMENT_TODO_LI, ELEMENT_TR, ELEMENT_UL, MARK_BG_COLOR, MARK_BOLD, MARK_CODE, MARK_COLOR, MARK_FONT_FAMILY, MARK_FONT_SIZE, MARK_FONT_WEIGHT, MARK_HIGHLIGHT, MARK_ITALIC, MARK_KBD, MARK_SEARCH_HIGHLIGHT, MARK_STRIKETHROUGH, MARK_SUBSCRIPT, MARK_SUPERSCRIPT, MARK_UNDERLINE, } from '@udecode/plate';
|
|
2
|
-
export const ELEMENT_AUDIO = 'audio';
|
|
3
|
-
export const ELEMENT_BIBLE_QUOTE = 'bible-quote';
|
|
4
2
|
export const ELEMENT_BUTTON = 'button';
|
|
5
|
-
export const ELEMENT_EXAMPLE = 'example';
|
|
6
|
-
export const ELEMENT_FOOTNOTE = 'footnote';
|
|
7
3
|
export const ELEMENT_PAYWALL = 'paywall';
|
|
8
|
-
export const ELEMENT_POLL = 'poll';
|
|
9
4
|
export const ELEMENT_QA = 'q-n-a';
|
|
10
|
-
export const ELEMENT_RECIPE = 'recipe';
|
|
11
5
|
export const ELEMENT_VIDEO = 'video';
|
|
12
6
|
export const BUTTON_LINK = 'button-link';
|
|
13
7
|
export const BUTTON_SUBSCRIBE = 'button-subscribe';
|
|
@@ -29,7 +23,16 @@ export const DEFAULT_CONTENT = [
|
|
|
29
23
|
},
|
|
30
24
|
],
|
|
31
25
|
questionAnswerId: 'q-n-a-ac0396ed-62ed-4a30-ba12-98f4fa2d364c',
|
|
32
|
-
type:
|
|
26
|
+
type: ELEMENT_QA,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
children: [
|
|
30
|
+
{
|
|
31
|
+
text: 'Episode 2: A Warrior’s Roadmap',
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
thumbnail: 'https://f005.backblazeb2.com/file/sr-platform/f7a84d1f4e70a940b63d7d6d96beab68.jpg',
|
|
35
|
+
type: ELEMENT_VIDEO,
|
|
33
36
|
},
|
|
34
37
|
{
|
|
35
38
|
children: [
|
|
@@ -9,9 +9,10 @@ export interface EditorProps {
|
|
|
9
9
|
}) => React.ReactElement;
|
|
10
10
|
communityName: string;
|
|
11
11
|
editable: boolean;
|
|
12
|
-
handleUploadImage
|
|
12
|
+
handleUploadImage?: (files: FileList) => Promise<string>;
|
|
13
|
+
handleVideoClick?: (id: number) => void;
|
|
13
14
|
onChange: (newNodes: TElement[]) => void;
|
|
14
15
|
previousContent?: TElement[];
|
|
15
16
|
}
|
|
16
17
|
export type EditorContent = TElement;
|
|
17
|
-
export declare const Editor: ({ commentInputLoader, commentLoader, editable, handleUploadImage, onChange, previousContent, }: EditorProps) => React.JSX.Element;
|
|
18
|
+
export declare const Editor: ({ commentInputLoader, commentLoader, editable, handleUploadImage, handleVideoClick, onChange, previousContent, }: EditorProps) => React.JSX.Element;
|
|
@@ -10,8 +10,12 @@ import { blocks, inline, marks, utils } from './plugins';
|
|
|
10
10
|
const plugins = createPlugins([...blocks, ...inline, ...marks, ...utils], {
|
|
11
11
|
components: plateUI,
|
|
12
12
|
});
|
|
13
|
-
export const Editor = ({ commentInputLoader, commentLoader, editable, handleUploadImage, onChange, previousContent = DEFAULT_CONTENT, }) => {
|
|
14
|
-
return (React.createElement(EditorContext.Provider, { value: {
|
|
13
|
+
export const Editor = ({ commentInputLoader, commentLoader, editable, handleUploadImage, handleVideoClick, onChange, previousContent = DEFAULT_CONTENT, }) => {
|
|
14
|
+
return (React.createElement(EditorContext.Provider, { value: {
|
|
15
|
+
commentInputLoader,
|
|
16
|
+
commentLoader,
|
|
17
|
+
handleVideoClick,
|
|
18
|
+
} },
|
|
15
19
|
React.createElement(Plate, { id: "main", initialValue: previousContent, onChange: onChange, plugins: plugins },
|
|
16
20
|
React.createElement(Wrapper, null,
|
|
17
21
|
editable && React.createElement(EditorBar, { handleUploadImage: handleUploadImage }),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export interface EditorBarProps {
|
|
3
|
-
handleUploadImage
|
|
3
|
+
handleUploadImage?: (files: FileList) => Promise<string>;
|
|
4
4
|
}
|
|
5
5
|
export declare const EditorBar: ({ handleUploadImage }: EditorBarProps) => React.JSX.Element;
|
|
6
6
|
export declare const MenuButton: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, {
|
|
@@ -61,7 +61,7 @@ export const EditorBar = ({ handleUploadImage }) => {
|
|
|
61
61
|
};
|
|
62
62
|
const handleImageChange = async () => {
|
|
63
63
|
const files = imageRef.current?.files;
|
|
64
|
-
if (!files)
|
|
64
|
+
if (!files || !handleUploadImage)
|
|
65
65
|
return;
|
|
66
66
|
const imageurl = await handleUploadImage(files);
|
|
67
67
|
if (imageurl) {
|
|
@@ -11,6 +11,7 @@ import { softBreakPlugin } from './softBreak';
|
|
|
11
11
|
import { createParagraphPlugin, createHOnePlugin, createHTwoPlugin, createHThreePlugin, createHFourPlugin, createHFivePlugin, createHSixPlugin, } from './text';
|
|
12
12
|
import { LinkFloatingMenu } from './link';
|
|
13
13
|
import { createQAPlugin } from './qa';
|
|
14
|
+
import { createVideoTitlePlugin } from './video';
|
|
14
15
|
/**
|
|
15
16
|
* ELEMENT TYPES
|
|
16
17
|
*/
|
|
@@ -60,6 +61,7 @@ export const blocks = [
|
|
|
60
61
|
createHSixPlugin(),
|
|
61
62
|
createResetNodePlugin(),
|
|
62
63
|
createTablePlugin(),
|
|
64
|
+
createVideoTitlePlugin(),
|
|
63
65
|
];
|
|
64
66
|
export const marks = [
|
|
65
67
|
createBoldPlugin(),
|
|
@@ -5,6 +5,7 @@ import { ELEMENT_QA } from '../constants';
|
|
|
5
5
|
import { EditorContext } from '../context';
|
|
6
6
|
import { Button } from '../../actions';
|
|
7
7
|
import { Box } from '../../atoms/box';
|
|
8
|
+
import { HideButRender } from '../../atoms/hide';
|
|
8
9
|
import { H } from '../../atoms/typography';
|
|
9
10
|
import { ChevronDown } from '../../../icons/arrow/chevron_down';
|
|
10
11
|
import { ChevronUp } from '../../../icons/arrow/chevron_up';
|
|
@@ -13,10 +14,10 @@ export const QuestionAnswerElement = React.forwardRef(({ children, element, ...p
|
|
|
13
14
|
const { commentInputLoader: CommentInput, commentLoader: Comments } = React.useContext(EditorContext);
|
|
14
15
|
const [showAnswers, setShowAnswers] = React.useState(false);
|
|
15
16
|
return (React.createElement(PlateElement, { asChild: true, element: element, ref: ref, ...props },
|
|
16
|
-
React.createElement(
|
|
17
|
+
React.createElement(React.Fragment, null,
|
|
17
18
|
React.createElement(Question, null,
|
|
18
19
|
React.createElement(H, { as: "p", "$fontSize": 18, "$lineHeight": 26, "$mediumBold": true }, children)),
|
|
19
|
-
React.createElement(Box, { "$dir": "column", "$gap": 24, "$padding": 24 },
|
|
20
|
+
React.createElement(Box, { "$dir": "column", "$gap": 24, "$padding": 24, ...{ contentEditable: false } },
|
|
20
21
|
React.createElement(Button, { as: "div", icon: showAnswers ? (React.createElement(ChevronUp, { color: "grey-3" })) : (React.createElement(ChevronDown, { color: "grey-3" })), onClick: () => setShowAnswers((prev) => !prev), size: "small", sx: `
|
|
21
22
|
width: fit-content;
|
|
22
23
|
flex-direction: row-reverse;
|
|
@@ -25,10 +26,12 @@ export const QuestionAnswerElement = React.forwardRef(({ children, element, ...p
|
|
|
25
26
|
fill: var(--color-grey-3);
|
|
26
27
|
}
|
|
27
28
|
`, type: "text", ...{ contentEditable: false } }, showAnswers ? 'Hide answers' : 'Show answers'),
|
|
28
|
-
|
|
29
|
+
React.createElement(HideButRender, { show: showAnswers },
|
|
30
|
+
React.createElement(Comments, { questionAnswerId: questionAnswerId })),
|
|
29
31
|
React.createElement(CommentInput, { questionAnswerId: questionAnswerId })))));
|
|
30
32
|
});
|
|
31
33
|
const Question = styled.div `
|
|
34
|
+
margin-bottom: 8px;
|
|
32
35
|
padding: 16px;
|
|
33
36
|
border-left: 8px solid var(--color-hue-blue-1);
|
|
34
37
|
border-radius: 8px;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { PlateElementProps } from '@udecode/plate';
|
|
3
|
+
export declare const VideoTitleElement: React.ForwardRefExoticComponent<Omit<PlateElementProps, "ref"> & React.RefAttributes<any>>;
|
|
4
|
+
export declare const createVideoTitlePlugin: <OP = import("@udecode/utils").AnyObject, OV extends import("@udecode/slate").Value = import("@udecode/slate").Value, OE extends import("@udecode/plate-core").PlateEditor<OV> = import("@udecode/plate-core").PlateEditor<OV>>(override?: Partial<import("@udecode/plate-core").PlatePlugin<import("@udecode/plate-core").NoInfer<OP>, OV, OE>> | undefined, overrideByKey?: import("@udecode/plate-core").OverrideByKey<OV, OE> | undefined) => import("@udecode/plate-core").PlatePlugin<import("@udecode/plate-core").NoInfer<OP>, OV, OE>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { createPluginFactory, isEditorReadOnly, PlateElement, } from '@udecode/plate';
|
|
3
|
+
import Image from 'next/image';
|
|
4
|
+
import { ELEMENT_H2, ELEMENT_VIDEO } from '../constants';
|
|
5
|
+
import { EditorContext } from '../context';
|
|
6
|
+
import { Box } from '../../atoms/box';
|
|
7
|
+
import { H } from '../../atoms/typography';
|
|
8
|
+
import { PlaySolid } from '../../../icons/audio_video/play_solid';
|
|
9
|
+
export const VideoTitleElement = React.forwardRef(function VideoTitle({ children, editor, element, ...props }, ref) {
|
|
10
|
+
const editable = !isEditorReadOnly(editor);
|
|
11
|
+
const { thumbnail, id } = element;
|
|
12
|
+
const { handleVideoClick } = React.useContext(EditorContext);
|
|
13
|
+
const handleClick = () => {
|
|
14
|
+
if (handleVideoClick && !editable) {
|
|
15
|
+
handleVideoClick(id);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
return (React.createElement(PlateElement, { asChild: true, editor: editor, element: element, ref: ref, ...props },
|
|
19
|
+
React.createElement(Box, { "$align": "center", "$gap": 24, onClick: handleClick, sx: editable ? '' : 'cursor: pointer;', ...{ contentEditable: false } },
|
|
20
|
+
React.createElement(Box, { "$align": "center", "$justify": "center", sx: "position: relative;" },
|
|
21
|
+
React.createElement(Image, { alt: "thumbnail", height: 96, src: thumbnail, style: {
|
|
22
|
+
borderRadius: '8px',
|
|
23
|
+
}, width: 171 }),
|
|
24
|
+
React.createElement(PlaySolid, { color: "white", size: 32, sx: "position: absolute;" })),
|
|
25
|
+
React.createElement(H, { as: "h2", "$bold": true, "$color": "grey-2", "$fontSize": 24, "$lineHeight": 36, "$textClampLines": 3 }, children))));
|
|
26
|
+
});
|
|
27
|
+
export const createVideoTitlePlugin = createPluginFactory({
|
|
28
|
+
key: ELEMENT_VIDEO,
|
|
29
|
+
type: ELEMENT_VIDEO,
|
|
30
|
+
isElement: true,
|
|
31
|
+
component: VideoTitleElement,
|
|
32
|
+
then: () => ({
|
|
33
|
+
inject: {
|
|
34
|
+
props: {
|
|
35
|
+
classNames: undefined,
|
|
36
|
+
validTypes: [ELEMENT_H2],
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
}),
|
|
40
|
+
});
|