@soul-refiner/design-system 1.3.3 → 1.4.1
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/editor/constants.d.ts +3 -3
- package/dist/components/editor/constants.js +2 -2
- package/dist/components/editor/context.d.ts +3 -0
- package/dist/components/editor/context.js +1 -0
- package/dist/components/editor/editor.d.ts +4 -1
- package/dist/components/editor/editor.js +3 -2
- package/dist/components/editor/plugins/video.js +6 -14
- package/package.json +1 -1
|
@@ -13,12 +13,12 @@ export declare const DEFAULT_CONTENT: ({
|
|
|
13
13
|
}[];
|
|
14
14
|
questionAnswerId: string;
|
|
15
15
|
type: string;
|
|
16
|
-
|
|
16
|
+
id?: undefined;
|
|
17
17
|
} | {
|
|
18
18
|
children: {
|
|
19
19
|
text: string;
|
|
20
20
|
}[];
|
|
21
|
-
|
|
21
|
+
id: number;
|
|
22
22
|
type: string;
|
|
23
23
|
questionAnswerId?: undefined;
|
|
24
24
|
} | {
|
|
@@ -27,5 +27,5 @@ export declare const DEFAULT_CONTENT: ({
|
|
|
27
27
|
}[];
|
|
28
28
|
type: string;
|
|
29
29
|
questionAnswerId?: undefined;
|
|
30
|
-
|
|
30
|
+
id?: undefined;
|
|
31
31
|
})[];
|
|
@@ -28,10 +28,10 @@ export const DEFAULT_CONTENT = [
|
|
|
28
28
|
{
|
|
29
29
|
children: [
|
|
30
30
|
{
|
|
31
|
-
text: '
|
|
31
|
+
text: '',
|
|
32
32
|
},
|
|
33
33
|
],
|
|
34
|
-
|
|
34
|
+
id: 1,
|
|
35
35
|
type: ELEMENT_VIDEO,
|
|
36
36
|
},
|
|
37
37
|
{
|
|
@@ -3,4 +3,5 @@ export const EditorContext = React.createContext({
|
|
|
3
3
|
commentInputLoader: () => React.createElement(React.Fragment, null),
|
|
4
4
|
commentLoader: () => React.createElement(React.Fragment, null),
|
|
5
5
|
handleVideoClick: () => undefined,
|
|
6
|
+
videoTitleLoader: () => React.createElement(React.Fragment, null),
|
|
6
7
|
});
|
|
@@ -13,6 +13,9 @@ export interface EditorProps {
|
|
|
13
13
|
handleVideoClick?: (id: number) => void;
|
|
14
14
|
onChange: (newNodes: TElement[]) => void;
|
|
15
15
|
previousContent?: TElement[];
|
|
16
|
+
videoTitleLoader: (props: {
|
|
17
|
+
courseMediaId: number;
|
|
18
|
+
}) => React.ReactElement;
|
|
16
19
|
}
|
|
17
20
|
export type EditorContent = TElement;
|
|
18
|
-
export declare const Editor: ({ commentInputLoader, commentLoader, editable, handleUploadImage, handleVideoClick, onChange, previousContent, }: EditorProps) => React.JSX.Element;
|
|
21
|
+
export declare const Editor: ({ commentInputLoader, commentLoader, editable, handleUploadImage, handleVideoClick, onChange, previousContent, videoTitleLoader, }: EditorProps) => React.JSX.Element;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import { createPlugins, Plate, PlateContent } from '@udecode/plate';
|
|
5
|
-
import {
|
|
5
|
+
import { PLACEHOLDER } from './constants';
|
|
6
6
|
import { EditorContext } from './context';
|
|
7
7
|
import { EditorBar } from './navbar';
|
|
8
8
|
import { plateUI } from './plate';
|
|
@@ -10,11 +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, handleVideoClick, onChange, previousContent
|
|
13
|
+
export const Editor = ({ commentInputLoader, commentLoader, editable, handleUploadImage, handleVideoClick, onChange, previousContent, videoTitleLoader, }) => {
|
|
14
14
|
return (React.createElement(EditorContext.Provider, { value: {
|
|
15
15
|
commentInputLoader,
|
|
16
16
|
commentLoader,
|
|
17
17
|
handleVideoClick,
|
|
18
|
+
videoTitleLoader,
|
|
18
19
|
} },
|
|
19
20
|
React.createElement(Plate, { id: "main", initialValue: previousContent, onChange: onChange, plugins: plugins },
|
|
20
21
|
React.createElement(Wrapper, null,
|
|
@@ -1,33 +1,25 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { createPluginFactory, isEditorReadOnly, PlateElement, } from '@udecode/plate';
|
|
3
|
-
import Image from 'next/image';
|
|
4
3
|
import { ELEMENT_H2, ELEMENT_VIDEO } from '../constants';
|
|
5
4
|
import { EditorContext } from '../context';
|
|
6
|
-
|
|
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) {
|
|
5
|
+
export const VideoTitleElement = React.forwardRef(function VideoTitle({ editor, element, ...props }, ref) {
|
|
10
6
|
const editable = !isEditorReadOnly(editor);
|
|
11
|
-
const {
|
|
12
|
-
const { handleVideoClick } = React.useContext(EditorContext);
|
|
7
|
+
const { id } = element;
|
|
8
|
+
const { handleVideoClick, videoTitleLoader: VideoTitle } = React.useContext(EditorContext);
|
|
13
9
|
const handleClick = () => {
|
|
14
10
|
if (handleVideoClick && !editable) {
|
|
15
11
|
handleVideoClick(id);
|
|
16
12
|
}
|
|
17
13
|
};
|
|
18
14
|
return (React.createElement(PlateElement, { asChild: true, editor: editor, element: element, ref: ref, ...props },
|
|
19
|
-
React.createElement(
|
|
20
|
-
React.createElement(
|
|
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))));
|
|
15
|
+
React.createElement("div", { contentEditable: false, onClick: handleClick, style: { cursor: editable ? 'initial' : 'pointer' } },
|
|
16
|
+
React.createElement(VideoTitle, { courseMediaId: id }))));
|
|
26
17
|
});
|
|
27
18
|
export const createVideoTitlePlugin = createPluginFactory({
|
|
28
19
|
key: ELEMENT_VIDEO,
|
|
29
20
|
type: ELEMENT_VIDEO,
|
|
30
21
|
isElement: true,
|
|
22
|
+
isVoid: true,
|
|
31
23
|
component: VideoTitleElement,
|
|
32
24
|
then: () => ({
|
|
33
25
|
inject: {
|