@soul-refiner/design-system 0.0.13 → 0.0.15

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.
Files changed (271) hide show
  1. package/.eslintrc.js +4 -0
  2. package/.turbo/turbo-build.log +12 -0
  3. package/.turbo/turbo-test.log +4417 -0
  4. package/CHANGELOG.md +7 -0
  5. package/babel.config.js +6 -0
  6. package/custom.d.ts +4 -0
  7. package/package.json +1 -13
  8. package/src/actions/Button/Button.module.scss +205 -0
  9. package/src/actions/Button/Button.spec.js +56 -0
  10. package/src/actions/Button/Button.tsx +143 -0
  11. package/src/actions/Button/index.ts +1 -0
  12. package/src/actions/Dropdown/Dropdown.module.scss +77 -0
  13. package/src/actions/Dropdown/Dropdown.spec.js +149 -0
  14. package/src/actions/Dropdown/Dropdown.tsx +224 -0
  15. package/src/actions/Dropdown/index.ts +6 -0
  16. package/src/actions/Dropzone/Dropzone.module.scss +48 -0
  17. package/src/actions/Dropzone/Dropzone.spec.js +60 -0
  18. package/src/actions/Dropzone/Dropzone.tsx +191 -0
  19. package/src/actions/Dropzone/index.ts +1 -0
  20. package/src/actions/Rate/Rate.module.scss +17 -0
  21. package/src/actions/Rate/Rate.tsx +53 -0
  22. package/src/actions/Rate/index.ts +1 -0
  23. package/src/actions/Switch/Switch.module.scss +35 -0
  24. package/src/actions/Switch/Switch.spec.js +31 -0
  25. package/src/actions/Switch/Switch.tsx +34 -0
  26. package/src/actions/Switch/index.ts +1 -0
  27. package/src/actions/index.ts +5 -0
  28. package/src/cards/CourseCard/CourseCard.module.scss +219 -0
  29. package/src/cards/CourseCard/CourseCard.spec.js +60 -0
  30. package/src/cards/CourseCard/CourseCard.tsx +145 -0
  31. package/src/cards/CourseCard/index.ts +1 -0
  32. package/src/cards/EpisodeCard/EpisodeCard.module.scss +69 -0
  33. package/src/cards/EpisodeCard/EpisodeCard.tsx +53 -0
  34. package/src/cards/EpisodeCard/index.ts +1 -0
  35. package/src/cards/FeatureCard/FeatureCard.module.scss +116 -0
  36. package/src/cards/FeatureCard/FeatureCard.spec.js +70 -0
  37. package/src/cards/FeatureCard/FeatureCard.tsx +123 -0
  38. package/src/cards/FeatureCard/index.ts +1 -0
  39. package/src/cards/index.ts +3 -0
  40. package/src/data/Bar/Bar.module.scss +105 -0
  41. package/src/data/Bar/Bar.tsx +161 -0
  42. package/src/data/Bar/index.ts +1 -0
  43. package/src/data/Line/Line.module.scss +102 -0
  44. package/src/data/Line/Line.tsx +162 -0
  45. package/src/data/Line/index.ts +1 -0
  46. package/src/data/Pie/Pie.module.scss +56 -0
  47. package/src/data/Pie/Pie.spec.js +72 -0
  48. package/src/data/Pie/Pie.tsx +111 -0
  49. package/src/data/Pie/index.ts +1 -0
  50. package/src/data/index.ts +3 -0
  51. package/src/editor/Editor.module.scss +125 -0
  52. package/src/editor/Editor.tsx +327 -0
  53. package/src/editor/common/elements.ts +50 -0
  54. package/src/editor/common/index.ts +2 -0
  55. package/src/editor/common/marks.ts +27 -0
  56. package/src/editor/components/MediaDrawer/MediaDrawer.module.scss +316 -0
  57. package/src/editor/components/MediaDrawer/MediaDrawer.tsx +457 -0
  58. package/src/editor/components/MediaDrawer/index.ts +1 -0
  59. package/src/editor/components/index.ts +1 -0
  60. package/src/editor/config/default.ts +213 -0
  61. package/src/editor/config/index.ts +2 -0
  62. package/src/editor/config/props.ts +9 -0
  63. package/src/editor/index.ts +2 -0
  64. package/src/editor/plateUI.ts +82 -0
  65. package/src/editor/plugins/blocks.tsx +71 -0
  66. package/src/editor/plugins/custom/assets/DefaultThumbnail.tsx +57 -0
  67. package/src/editor/plugins/custom/assets/index.ts +1 -0
  68. package/src/editor/plugins/custom/buttons.tsx +289 -0
  69. package/src/editor/plugins/custom/example.tsx +64 -0
  70. package/src/editor/plugins/custom/exitBreak.ts +41 -0
  71. package/src/editor/plugins/custom/footnote.tsx +185 -0
  72. package/src/editor/plugins/custom/index.ts +14 -0
  73. package/src/editor/plugins/custom/paywall.tsx +156 -0
  74. package/src/editor/plugins/custom/qa.tsx +390 -0
  75. package/src/editor/plugins/custom/resetBlockType.ts +29 -0
  76. package/src/editor/plugins/custom/selectOnBackspace.ts +7 -0
  77. package/src/editor/plugins/custom/softBreak.ts +20 -0
  78. package/src/editor/plugins/custom/styles/Button.module.scss +51 -0
  79. package/src/editor/plugins/custom/styles/Footnote.module.scss +58 -0
  80. package/src/editor/plugins/custom/styles/Paywall.module.scss +67 -0
  81. package/src/editor/plugins/custom/styles/QA.module.scss +140 -0
  82. package/src/editor/plugins/custom/styles/Video.module.scss +79 -0
  83. package/src/editor/plugins/custom/video.tsx +163 -0
  84. package/src/editor/plugins/index.ts +18 -0
  85. package/src/editor/plugins/inline.ts +46 -0
  86. package/src/editor/plugins/marks.ts +25 -0
  87. package/src/editor/plugins/utils.ts +22 -0
  88. package/src/feedback/Chip/Chip.module.scss +23 -0
  89. package/src/feedback/Chip/Chip.tsx +58 -0
  90. package/src/feedback/Chip/index.ts +1 -0
  91. package/src/feedback/Loader/Loader.module.scss +18 -0
  92. package/src/feedback/Loader/Loader.spec.js +18 -0
  93. package/src/feedback/Loader/Loader.tsx +53 -0
  94. package/src/feedback/Loader/index.ts +1 -0
  95. package/src/feedback/ProgressBar/ProgressBar.module.scss +13 -0
  96. package/src/feedback/ProgressBar/ProgressBar.tsx +32 -0
  97. package/src/feedback/ProgressBar/index.ts +1 -0
  98. package/src/feedback/Toast/Toast.module.scss +44 -0
  99. package/src/feedback/Toast/Toast.tsx +76 -0
  100. package/src/feedback/Toast/index.ts +1 -0
  101. package/src/feedback/Tooltip/Tooltip.module.scss +47 -0
  102. package/src/feedback/Tooltip/Tooltip.tsx +10 -0
  103. package/src/feedback/Tooltip/index.ts +1 -0
  104. package/src/feedback/index.ts +5 -0
  105. package/src/global.d.ts +6 -0
  106. package/src/iconography/Avatar/Avatar.module.scss +90 -0
  107. package/src/iconography/Avatar/Avatar.spec.js +75 -0
  108. package/src/iconography/Avatar/Avatar.tsx +96 -0
  109. package/src/iconography/Avatar/DefaultIcon.svg +4 -0
  110. package/src/iconography/Avatar/DefaultIcon.tsx +12 -0
  111. package/src/iconography/Avatar/iconHelpers.tsx +186 -0
  112. package/src/iconography/Avatar/index.ts +1 -0
  113. package/src/iconography/ColoredIcon/ColoredIcon.module.scss +40 -0
  114. package/src/iconography/ColoredIcon/ColoredIcon.tsx +30 -0
  115. package/src/iconography/ColoredIcon/index.ts +5 -0
  116. package/src/iconography/DevicePreview/DevicePreview.module.scss +143 -0
  117. package/src/iconography/DevicePreview/DevicePreview.tsx +592 -0
  118. package/src/iconography/DevicePreview/index.ts +1 -0
  119. package/src/iconography/IconHeader/IconHeader.module.scss +42 -0
  120. package/src/iconography/IconHeader/IconHeader.tsx +42 -0
  121. package/src/iconography/IconHeader/index.ts +1 -0
  122. package/src/iconography/StarRating/StarRating.tsx +99 -0
  123. package/src/iconography/StarRating/index.ts +1 -0
  124. package/src/iconography/index.ts +5 -0
  125. package/src/implementations/BodyContent/BodyContent.module.scss +38 -0
  126. package/src/implementations/BodyContent/BodyContent.tsx +78 -0
  127. package/src/implementations/BodyContent/index.ts +2 -0
  128. package/src/implementations/JoinGroupModal/JoinGroupModal.module.scss +83 -0
  129. package/src/implementations/JoinGroupModal/JoinGroupModal.tsx +176 -0
  130. package/src/implementations/JoinGroupModal/index.ts +1 -0
  131. package/src/implementations/index.ts +2 -0
  132. package/src/index.ts +149 -0
  133. package/src/inputs/CalendarInput/CalendarInput.module.scss +38 -0
  134. package/src/inputs/CalendarInput/CalendarInput.spec.js +19 -0
  135. package/src/inputs/CalendarInput/CalendarInput.tsx +29 -0
  136. package/src/inputs/CalendarInput/index.ts +1 -0
  137. package/src/inputs/CheckboxInput/CheckboxInput.module.scss +23 -0
  138. package/src/inputs/CheckboxInput/CheckboxInput.tsx +39 -0
  139. package/src/inputs/CheckboxInput/index.ts +1 -0
  140. package/src/inputs/FeedInput/FeedInput.module.scss +48 -0
  141. package/src/inputs/FeedInput/FeedInput.spec.js +16 -0
  142. package/src/inputs/FeedInput/FeedInput.tsx +197 -0
  143. package/src/inputs/FeedInput/index.ts +1 -0
  144. package/src/inputs/InboxInput/InboxInput.module.scss +48 -0
  145. package/src/inputs/InboxInput/InboxInput.spec.js +19 -0
  146. package/src/inputs/InboxInput/InboxInput.tsx +97 -0
  147. package/src/inputs/InboxInput/index.ts +1 -0
  148. package/src/inputs/PostInput/PostInput.module.scss +49 -0
  149. package/src/inputs/PostInput/PostInput.spec.js +19 -0
  150. package/src/inputs/PostInput/PostInput.tsx +54 -0
  151. package/src/inputs/PostInput/index.ts +1 -0
  152. package/src/inputs/RadioInput/RadioInput.module.scss +68 -0
  153. package/src/inputs/RadioInput/RadioInput.tsx +55 -0
  154. package/src/inputs/RadioInput/index.ts +1 -0
  155. package/src/inputs/SearchInput/SearchInput.module.scss +40 -0
  156. package/src/inputs/SearchInput/SearchInput.tsx +61 -0
  157. package/src/inputs/SearchInput/index.ts +1 -0
  158. package/src/inputs/SelectInput/SelectInput.module.scss +66 -0
  159. package/src/inputs/SelectInput/SelectInput.tsx +145 -0
  160. package/src/inputs/SelectInput/index.ts +1 -0
  161. package/src/inputs/TagInput/TagInput.module.scss +75 -0
  162. package/src/inputs/TagInput/TagInput.tsx +115 -0
  163. package/src/inputs/TagInput/index.ts +1 -0
  164. package/src/inputs/TextInput/TextInput.module.scss +35 -0
  165. package/src/inputs/TextInput/TextInput.tsx +46 -0
  166. package/src/inputs/TextInput/index.ts +1 -0
  167. package/src/inputs/index.ts +10 -0
  168. package/src/lists/ContactDetails/ContactDetails.module.scss +70 -0
  169. package/src/lists/ContactDetails/ContactDetails.spec.js +69 -0
  170. package/src/lists/ContactDetails/ContactDetails.tsx +185 -0
  171. package/src/lists/ContactDetails/index.ts +1 -0
  172. package/src/lists/index.ts +1 -0
  173. package/src/navigation/Breadcrumbs/Breadcrumbs.module.scss +18 -0
  174. package/src/navigation/Breadcrumbs/Breadcrumbs.spec.js +38 -0
  175. package/src/navigation/Breadcrumbs/Breadcrumbs.tsx +43 -0
  176. package/src/navigation/Breadcrumbs/index.ts +1 -0
  177. package/src/navigation/Drawer/Drawer.module.scss +104 -0
  178. package/src/navigation/Drawer/Drawer.tsx +177 -0
  179. package/src/navigation/Drawer/index.ts +1 -0
  180. package/src/navigation/EditorBar/EditorBar.module.scss +118 -0
  181. package/src/navigation/EditorBar/EditorBar.tsx +416 -0
  182. package/src/navigation/EditorBar/components/AlignmentDropdown/AlignmentDropdown.tsx +106 -0
  183. package/src/navigation/EditorBar/components/AlignmentDropdown/index.ts +1 -0
  184. package/src/navigation/EditorBar/components/ButtonModal/ButtonModal.module.scss +85 -0
  185. package/src/navigation/EditorBar/components/ButtonModal/ButtonModal.tsx +314 -0
  186. package/src/navigation/EditorBar/components/ButtonModal/assets/Comment.tsx +28 -0
  187. package/src/navigation/EditorBar/components/ButtonModal/assets/GiftSubscription.tsx +28 -0
  188. package/src/navigation/EditorBar/components/ButtonModal/assets/Link.tsx +28 -0
  189. package/src/navigation/EditorBar/components/ButtonModal/assets/Share.tsx +28 -0
  190. package/src/navigation/EditorBar/components/ButtonModal/assets/ShareCommunity.tsx +42 -0
  191. package/src/navigation/EditorBar/components/ButtonModal/assets/Signup.tsx +68 -0
  192. package/src/navigation/EditorBar/components/ButtonModal/assets/Special.tsx +24 -0
  193. package/src/navigation/EditorBar/components/ButtonModal/assets/Subscribe.tsx +28 -0
  194. package/src/navigation/EditorBar/components/ButtonModal/assets/index.ts +8 -0
  195. package/src/navigation/EditorBar/components/ButtonModal/index.ts +1 -0
  196. package/src/navigation/EditorBar/components/FontDropdown/FontDropdown.module.scss +16 -0
  197. package/src/navigation/EditorBar/components/FontDropdown/FontDropdown.tsx +137 -0
  198. package/src/navigation/EditorBar/components/FontDropdown/index.ts +1 -0
  199. package/src/navigation/EditorBar/components/MoreDropdown/MoreDropdown.module.scss +43 -0
  200. package/src/navigation/EditorBar/components/MoreDropdown/MoreDropdown.tsx +124 -0
  201. package/src/navigation/EditorBar/components/MoreDropdown/index.ts +1 -0
  202. package/src/navigation/EditorBar/components/OutlineDropdown/OutlineDropdown.module.scss +21 -0
  203. package/src/navigation/EditorBar/components/OutlineDropdown/OutlineDropdown.tsx +37 -0
  204. package/src/navigation/EditorBar/components/OutlineDropdown/index.ts +1 -0
  205. package/src/navigation/EditorBar/components/TextTypeDropdown/TextTypeDropdown.module.scss +51 -0
  206. package/src/navigation/EditorBar/components/TextTypeDropdown/TextTypeDropdown.tsx +80 -0
  207. package/src/navigation/EditorBar/components/TextTypeDropdown/index.ts +1 -0
  208. package/src/navigation/EditorBar/components/VideoModal/VideoModal.module.scss +150 -0
  209. package/src/navigation/EditorBar/components/VideoModal/VideoModal.tsx +163 -0
  210. package/src/navigation/EditorBar/components/VideoModal/index.ts +1 -0
  211. package/src/navigation/EditorBar/components/index.ts +7 -0
  212. package/src/navigation/EditorBar/index.ts +1 -0
  213. package/src/navigation/MenuTabs/MenuTabs.module.scss +34 -0
  214. package/src/navigation/MenuTabs/MenuTabs.spec.js +36 -0
  215. package/src/navigation/MenuTabs/MenuTabs.tsx +52 -0
  216. package/src/navigation/MenuTabs/index.ts +1 -0
  217. package/src/navigation/Navigation/Navigation.module.scss +92 -0
  218. package/src/navigation/Navigation/Navigation.spec.js +144 -0
  219. package/src/navigation/Navigation/Navigation.tsx +111 -0
  220. package/src/navigation/Navigation/SubNavigation.module.scss +255 -0
  221. package/src/navigation/Navigation/SubNavigation.spec.js +112 -0
  222. package/src/navigation/Navigation/SubNavigation.tsx +443 -0
  223. package/src/navigation/Navigation/index.ts +15 -0
  224. package/src/navigation/Pagination/Pagination.module.scss +49 -0
  225. package/src/navigation/Pagination/Pagination.tsx +115 -0
  226. package/src/navigation/Pagination/index.ts +1 -0
  227. package/src/navigation/index.ts +21 -0
  228. package/src/surfaces/Comment/Comment.module.scss +106 -0
  229. package/src/surfaces/Comment/Comment.spec.js +105 -0
  230. package/src/surfaces/Comment/Comment.tsx +157 -0
  231. package/src/surfaces/Comment/index.ts +1 -0
  232. package/src/surfaces/Faq/Faq.module.scss +91 -0
  233. package/src/surfaces/Faq/Faq.spec.js +38 -0
  234. package/src/surfaces/Faq/Faq.tsx +156 -0
  235. package/src/surfaces/Faq/index.ts +1 -0
  236. package/src/surfaces/Message/Message.module.scss +37 -0
  237. package/src/surfaces/Message/Message.spec.js +47 -0
  238. package/src/surfaces/Message/Message.tsx +54 -0
  239. package/src/surfaces/Message/index.ts +1 -0
  240. package/src/surfaces/Modal/Modal.module.scss +52 -0
  241. package/src/surfaces/Modal/Modal.spec.js +38 -0
  242. package/src/surfaces/Modal/Modal.tsx +131 -0
  243. package/src/surfaces/Modal/index.ts +5 -0
  244. package/src/surfaces/Plan/Plan.module.scss +79 -0
  245. package/src/surfaces/Plan/Plan.tsx +75 -0
  246. package/src/surfaces/Plan/index.ts +1 -0
  247. package/src/surfaces/Post/Post.module.scss +46 -0
  248. package/src/surfaces/Post/Post.spec.js +103 -0
  249. package/src/surfaces/Post/Post.tsx +185 -0
  250. package/src/surfaces/Post/index.ts +1 -0
  251. package/src/surfaces/Post/postHelpers.ts +20 -0
  252. package/src/surfaces/ProfileHeader/ProfileHeader.module.scss +202 -0
  253. package/src/surfaces/ProfileHeader/ProfileHeader.tsx +103 -0
  254. package/src/surfaces/ProfileHeader/index.ts +1 -0
  255. package/src/surfaces/RatingsOverview/RatingsOverview.module.scss +54 -0
  256. package/src/surfaces/RatingsOverview/RatingsOverview.tsx +69 -0
  257. package/src/surfaces/RatingsOverview/index.ts +1 -0
  258. package/src/surfaces/Review/Review.module.scss +73 -0
  259. package/src/surfaces/Review/Review.tsx +88 -0
  260. package/src/surfaces/Review/index.ts +1 -0
  261. package/src/surfaces/index.ts +9 -0
  262. package/src/tables/Filter/Filter.module.scss +34 -0
  263. package/src/tables/Filter/Filter.tsx +30 -0
  264. package/src/tables/Filter/index.ts +1 -0
  265. package/src/tables/Table/Table.module.scss +126 -0
  266. package/src/tables/Table/Table.spec.js +113 -0
  267. package/src/tables/Table/Table.tsx +251 -0
  268. package/src/tables/Table/index.ts +7 -0
  269. package/src/tables/index.ts +7 -0
  270. package/tsconfig.json +14 -0
  271. package/vite.config.ts +28 -0
@@ -0,0 +1,327 @@
1
+ import React from "react";
2
+ import {
3
+ Comment,
4
+ Course,
5
+ CourseContent,
6
+ Media,
7
+ User,
8
+ } from "@soul-refiner/models";
9
+ import { createPlugins, Plate, PlateProvider, TElement } from "@udecode/plate";
10
+ import Client from "@soul-refiner/client";
11
+
12
+ import { plateUI } from "./plateUI";
13
+ import { DEFAULT_CONTENT, editableProps } from "./config";
14
+ import { blocks, inline, marks, utils } from "./plugins";
15
+
16
+ import { EditorBar } from "../navigation/EditorBar";
17
+
18
+ import styles from "./Editor.module.scss";
19
+
20
+ /**********************************************************************
21
+ * Types
22
+ */
23
+ export interface EditorProps extends Course {
24
+ defaultContent?: TElement[];
25
+ editable: boolean;
26
+ handleAddComment: (newComment: {
27
+ user: User;
28
+ text: string;
29
+ parentId: string;
30
+ }) => void;
31
+ handleAddReaction: (newReaction: {
32
+ parentId: string;
33
+ type: "like" | "dislike";
34
+ userId: string;
35
+ }) => void;
36
+ handleChangeVideo: (video: Partial<Media>) => Promise<Media>;
37
+ handleCourseChange: (newCourse: Partial<Course>) => void;
38
+ handleDeleteVideo: (id: string) => void;
39
+ handleGetComments: (id: string) => Promise<Comment[]>;
40
+ handleGetFriends: (query: string, selected?: string[]) => Promise<User[]>;
41
+ handleGetVideos: () => Promise<Media[]>;
42
+ handleSetVideoSrc: (src: string) => void;
43
+ handleUploadImage: (dataURL: File) => Promise<string>;
44
+ handleUploadVideo: (
45
+ dataURL: File,
46
+ previous?: Partial<Media>
47
+ ) => Promise<Media>;
48
+ pageName: string;
49
+ user: User;
50
+ }
51
+
52
+ export interface EditorContextProps
53
+ extends Omit<EditorProps, "defaultContent"> {
54
+ availableVideos: Media[];
55
+ isUserAuthorized: boolean;
56
+ footnotes: { id: string; text: string }[];
57
+ handleFootnoteChange: (id: string, text: string) => void;
58
+ handleFootnoteDelete: (id: string) => void;
59
+ }
60
+
61
+ /**********************************************************************
62
+ * Editor Configuration
63
+ */
64
+
65
+ const plugins = createPlugins([...blocks, ...inline, ...marks, ...utils], {
66
+ components: plateUI,
67
+ });
68
+
69
+ /**********************************************************************
70
+ * Context
71
+ */
72
+
73
+ export const EditorContext = React.createContext<EditorContextProps>({
74
+ availableVideos: [],
75
+ categories: [],
76
+ created: "",
77
+ description: "",
78
+ editable: false,
79
+ footnotes: [],
80
+ handleAddComment: (post) => undefined,
81
+ handleAddReaction: (newReaction) => undefined,
82
+ handleChangeVideo: async (video) => ({} as Media),
83
+ handleCourseChange: (newCourse) => undefined,
84
+ handleDeleteVideo: (id) => undefined,
85
+ handleGetComments: async (id) => [],
86
+ handleGetFriends: async (query) => [],
87
+ handleGetVideos: async () => [],
88
+ handleFootnoteChange: (id, text) => undefined,
89
+ handleFootnoteDelete: (id) => undefined,
90
+ handleSetVideoSrc: (src) => undefined,
91
+ handleUploadImage: async (upload: File) => "",
92
+ handleUploadVideo: async (upload: File) => ({} as Media),
93
+ hasContent: true,
94
+ id: "",
95
+ isUserAuthorized: false,
96
+ modified: "",
97
+ outline: [],
98
+ ownerId: "",
99
+ pageName: "",
100
+ plans: [],
101
+ ratings: [],
102
+ sampleVideo: "",
103
+ shortDescription: "",
104
+ status: "draft",
105
+ subtitle: "",
106
+ tags: [],
107
+ thumbnail: "",
108
+ title: "",
109
+ trailerVideo: "",
110
+ type: "written",
111
+ user: {} as User,
112
+ });
113
+
114
+ /**********************************************************************
115
+ * Function
116
+ */
117
+ export const Editor = ({
118
+ categories,
119
+ created,
120
+ defaultContent = DEFAULT_CONTENT,
121
+ description,
122
+ editable = true,
123
+ handleAddComment,
124
+ handleAddReaction,
125
+ handleChangeVideo,
126
+ handleCourseChange,
127
+ handleDeleteVideo,
128
+ handleGetComments,
129
+ handleGetFriends,
130
+ handleGetVideos,
131
+ handleSetVideoSrc,
132
+ handleUploadImage,
133
+ handleUploadVideo,
134
+ hasContent,
135
+ id,
136
+ modified,
137
+ outline,
138
+ ownerId,
139
+ pageName,
140
+ plans,
141
+ ratings,
142
+ sampleVideo,
143
+ shortDescription,
144
+ status,
145
+ subtitle,
146
+ tags,
147
+ thumbnail,
148
+ title,
149
+ trailerVideo,
150
+ type,
151
+ user,
152
+ }: EditorProps) => {
153
+ const [saving, setSaving] = React.useState(false);
154
+ const [errorSaving, setErrorSaving] = React.useState(false);
155
+ const [footnotes, setFootnotes] = React.useState<
156
+ { id: string; text: string }[]
157
+ >([]);
158
+ const [contentState, setContentState] = React.useState<CourseContent>({
159
+ courseId: id,
160
+ created: new Date().toISOString(),
161
+ nodes: [],
162
+ status: "draft",
163
+ });
164
+ const [availableVideos, setAvailableVideos] = React.useState<Media[]>([]);
165
+
166
+ let client: Client;
167
+
168
+ const handleChange = (newNodes: TElement[]) => {
169
+ setContentState((prev) => ({
170
+ ...prev,
171
+ created: new Date().toISOString(),
172
+ nodes: newNodes as any,
173
+ }));
174
+ };
175
+
176
+ const handleFootnoteChange = (id: string, text: string) => {
177
+ setFootnotes((prev) => {
178
+ const index = prev.findIndex((footnote) => footnote.id === id);
179
+ if (index === -1 && text !== "") {
180
+ return [...prev, { id, text }];
181
+ }
182
+ if (text !== "") {
183
+ const newFootnotes = prev;
184
+ newFootnotes.splice(index, 1, { id, text });
185
+ return newFootnotes;
186
+ }
187
+ return prev;
188
+ });
189
+ };
190
+
191
+ const handleFootnoteDelete = (id: string) => {
192
+ setFootnotes((prev) => {
193
+ const index = prev.findIndex((footnote) => footnote.id === id);
194
+ if (index === -1) return prev;
195
+ const newFootnotes = prev;
196
+ prev.splice(index, 1);
197
+ return newFootnotes;
198
+ });
199
+ };
200
+
201
+ const isUserAuthorized = React.useMemo(() => {
202
+ if (user?.id) {
203
+ /**
204
+ * TODO: Handle authorization of user to view content;
205
+ */
206
+ return true;
207
+ }
208
+ return false;
209
+ }, [user?.id]);
210
+
211
+ React.useEffect(() => {
212
+ client = new Client({ token: "new-token" });
213
+ const controller = new AbortController();
214
+
215
+ (async () => {
216
+ const content = await client.courses.getContentById(id, {
217
+ signal: controller.signal,
218
+ });
219
+ if (content) setContentState(content.data);
220
+ })();
221
+
222
+ setInterval(async () => {
223
+ setSaving(true);
224
+ const save = await client.courses.upsertCourseContent({
225
+ courseId: id,
226
+ nodes: contentState?.nodes ?? [],
227
+ });
228
+ if (save?.data) {
229
+ setErrorSaving(false);
230
+ setSaving(false);
231
+ } else {
232
+ setErrorSaving(true);
233
+ // TODO: Determine what happens after it fails to save
234
+ }
235
+ }, 300000);
236
+
237
+ handleGetVideos().then((res) => setAvailableVideos(res));
238
+
239
+ return () => {
240
+ controller.abort();
241
+ client.courses.upsertCourseContent({
242
+ courseId: id,
243
+ nodes: contentState?.nodes ?? [],
244
+ });
245
+ };
246
+ }, []);
247
+
248
+ // React.useEffect(() => {
249
+ // /**
250
+ // * Limit the content if user is not authorized to see it
251
+ // * TODO: DO THIS ON THE BACKEND
252
+ // */
253
+ // if (!isUserAuthorized) {
254
+ // let paywallOccurance = false;
255
+ // setPlateValue(
256
+ // (contentState.nodes as unknown as TElement[]).filter((element) => {
257
+ // const value = paywallOccurance;
258
+ // if (element.type === ELEMENT_PAYWALL) paywallOccurance = true;
259
+ // return value;
260
+ // })
261
+ // );
262
+ // }
263
+ // }, [isUserAuthorized]);
264
+
265
+ return (
266
+ <EditorContext.Provider
267
+ value={{
268
+ availableVideos,
269
+ categories,
270
+ created,
271
+ description,
272
+ editable,
273
+ footnotes,
274
+ handleAddComment,
275
+ handleAddReaction,
276
+ handleChangeVideo,
277
+ handleCourseChange,
278
+ handleDeleteVideo,
279
+ handleGetComments,
280
+ handleGetFriends,
281
+ handleGetVideos,
282
+ handleFootnoteChange,
283
+ handleFootnoteDelete,
284
+ handleSetVideoSrc,
285
+ handleUploadImage,
286
+ handleUploadVideo,
287
+ hasContent,
288
+ id,
289
+ isUserAuthorized,
290
+ modified,
291
+ ownerId,
292
+ outline,
293
+ pageName,
294
+ plans,
295
+ ratings,
296
+ sampleVideo,
297
+ status,
298
+ shortDescription,
299
+ subtitle,
300
+ tags,
301
+ title,
302
+ thumbnail,
303
+ trailerVideo,
304
+ type,
305
+ user,
306
+ }}
307
+ >
308
+ <PlateProvider
309
+ id="main"
310
+ initialValue={defaultContent}
311
+ onChange={handleChange}
312
+ plugins={plugins}
313
+ >
314
+ <EditorBar editable={editable} />
315
+ <div className={styles.editor}>
316
+ <Plate
317
+ id="main"
318
+ editableProps={{
319
+ readOnly: !editable,
320
+ ...editableProps,
321
+ }}
322
+ />
323
+ </div>
324
+ </PlateProvider>
325
+ </EditorContext.Provider>
326
+ );
327
+ };
@@ -0,0 +1,50 @@
1
+ export {
2
+ ELEMENT_BLOCKQUOTE,
3
+ ELEMENT_CODE_BLOCK,
4
+ ELEMENT_CODE_LINE,
5
+ ELEMENT_CODE_SYNTAX,
6
+ ELEMENT_DEFAULT,
7
+ ELEMENT_H1,
8
+ ELEMENT_H2,
9
+ ELEMENT_H3,
10
+ ELEMENT_H4,
11
+ ELEMENT_H5,
12
+ ELEMENT_H6,
13
+ ELEMENT_HR,
14
+ ELEMENT_IMAGE,
15
+ ELEMENT_LI,
16
+ ELEMENT_LIC,
17
+ ELEMENT_LINK,
18
+ ELEMENT_MEDIA,
19
+ ELEMENT_MEDIA_EMBED,
20
+ ELEMENT_MENTION,
21
+ ELEMENT_MENTION_INPUT,
22
+ ELEMENT_OL,
23
+ ELEMENT_PARAGRAPH,
24
+ ELEMENT_TABLE,
25
+ ELEMENT_TD,
26
+ ELEMENT_TH,
27
+ ELEMENT_TODO_LI,
28
+ ELEMENT_TR,
29
+ ELEMENT_UL,
30
+ } from "@udecode/plate";
31
+
32
+ export const ELEMENT_AUDIO = "audio";
33
+ export const ELEMENT_BIBLE_QUOTE = "bible-quote";
34
+ export const ELEMENT_BUTTON = "button";
35
+ export const ELEMENT_EXAMPLE = "example";
36
+ export const ELEMENT_FOOTNOTE = "footnote";
37
+ export const ELEMENT_PAYWALL = "paywall";
38
+ export const ELEMENT_POLL = "poll";
39
+ export const ELEMENT_QA = "q-n-a";
40
+ export const ELEMENT_RECIPE = "recipe";
41
+ export const ELEMENT_VIDEO = "video";
42
+
43
+ export const BUTTON_COMMENT = "button-comment";
44
+ export const BUTTON_GIFT_SUBSCRIPTION = "button-gift-subscription";
45
+ export const BUTTON_LINK = "button-link";
46
+ export const BUTTON_SHARE = "button-share";
47
+ export const BUTTON_SHARE_PAGE = "button-share-page";
48
+ export const BUTTON_SIGNUP = "signup";
49
+ export const BUTTON_SPECIAL_OFFER = "button-special-offer";
50
+ export const BUTTON_SUBSCRIBE = "button-subscribe";
@@ -0,0 +1,2 @@
1
+ export * from "./elements";
2
+ export * from "./marks";
@@ -0,0 +1,27 @@
1
+ export {
2
+ MARK_BG_COLOR,
3
+ MARK_BOLD,
4
+ MARK_CODE,
5
+ MARK_COLOR,
6
+ MARK_FONT_FAMILY,
7
+ MARK_FONT_SIZE,
8
+ MARK_FONT_WEIGHT,
9
+ MARK_HIGHLIGHT,
10
+ MARK_ITALIC,
11
+ MARK_KBD,
12
+ MARK_SEARCH_HIGHLIGHT,
13
+ MARK_STRIKETHROUGH,
14
+ MARK_SUBSCRIPT,
15
+ MARK_SUPERSCRIPT,
16
+ MARK_UNDERLINE,
17
+ } from "@udecode/plate";
18
+
19
+ export const COLORS = [
20
+ "var(--color-turquoise-5)",
21
+ "var(--color-green-5)",
22
+ "var(--color-blue-5)",
23
+ "var(--color-purple-5)",
24
+ "var(--color-yellow-5)",
25
+ "var(--color-orange-5)",
26
+ "var(--color-red-5)",
27
+ ];
@@ -0,0 +1,316 @@
1
+ @use "@soul-refiner/styles/mixins";
2
+
3
+ .drawer {
4
+ .mediaName {
5
+ @include mixins.font(500, 24px, 30px);
6
+ margin-top: 14px;
7
+ margin-left: 12px;
8
+ }
9
+
10
+ [class~="icon-header"] {
11
+ & > * {
12
+ color: inherit;
13
+ & > * {
14
+ color: inherit;
15
+ }
16
+ }
17
+ h5 {
18
+ font-weight: 700;
19
+ }
20
+ }
21
+
22
+ [class~="actions-wrapper"] {
23
+ button:last-of-type > span {
24
+ color: #ffffff;
25
+ }
26
+ }
27
+
28
+ .details {
29
+ h6 {
30
+ line-height: 24px;
31
+ font-weight: 700;
32
+ }
33
+ p {
34
+ @include mixins.font(400, 16px, 24px);
35
+ margin-bottom: 16px;
36
+ color: var(--color-grey-6);
37
+ }
38
+
39
+ div {
40
+ margin-bottom: 32px;
41
+ }
42
+ }
43
+
44
+ .media {
45
+ width: 100%;
46
+ [class~="switch"] {
47
+ width: 350px;
48
+ border-radius: 8px;
49
+ background-color: var(--color-grey-9);
50
+ & > div {
51
+ border-radius: 8px;
52
+ color: var(--color-grey-4);
53
+ &[class~="active"] {
54
+ font-weight: 700;
55
+ color: var(--color-blue-3);
56
+ }
57
+ }
58
+ }
59
+
60
+ .contentWrapper {
61
+ width: 100%;
62
+ margin: 32px 0px;
63
+
64
+ & > * {
65
+ width: 100%;
66
+ }
67
+
68
+ div > div > button {
69
+ background-color: transparent;
70
+ }
71
+
72
+ div > div > button > span {
73
+ color: var(--color-purple-5);
74
+ }
75
+
76
+ .select {
77
+ & > div {
78
+ padding: 12px 32px 12px 12px;
79
+ border-radius: 8px;
80
+ height: fit-content !important;
81
+ input {
82
+ width: 333px;
83
+ height: 24px;
84
+ padding-right: 24px;
85
+ }
86
+ }
87
+
88
+ .videoWrapper {
89
+ max-height: 271px;
90
+ overflow-y: auto;
91
+ @include mixins.flex($gap: 12px, $dir: column);
92
+
93
+ &::-webkit-scrollbar-track {
94
+ margin: 25px;
95
+ }
96
+
97
+ .video {
98
+ @include mixins.flex(
99
+ $gap: 20px,
100
+ $align: center,
101
+ $justify: space-between
102
+ );
103
+ width: 100%;
104
+ position: relative;
105
+ height: 104px;
106
+ padding: 16px 24px;
107
+ border: 1px solid rgba(0, 0, 0, 0.06);
108
+ box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
109
+ border-radius: 8px;
110
+ cursor: pointer;
111
+
112
+ &:hover {
113
+ border-bottom: 1px solid transparent;
114
+ background-color: var(--color-grey-9);
115
+ border-radius: 8px;
116
+ }
117
+
118
+ .thumbnailWrapper {
119
+ height: 100%;
120
+ position: relative;
121
+ img {
122
+ height: 100%;
123
+ object-fit: contain;
124
+ border-radius: 8px;
125
+ }
126
+ .duration {
127
+ @include mixins.font(600, 10px, 15px);
128
+ display: block;
129
+ position: absolute;
130
+ right: 7px;
131
+ bottom: 5px;
132
+ color: #ffffff;
133
+ padding: 4px;
134
+ border-radius: 4px;
135
+ background-color: rgba(0, 0, 0, 0.5);
136
+ letter-spacing: 0.5px;
137
+ }
138
+ }
139
+
140
+ .selected {
141
+ width: 22px;
142
+ height: 22px;
143
+ box-sizing: border-box;
144
+ border: 1px solid var(--color-grey-8);
145
+ border-radius: 50%;
146
+ flex-shrink: 0;
147
+ margin-left: auto;
148
+ background-color: #ffffff;
149
+
150
+ &[class~="active"] {
151
+ border: 5px solid var(--color-blue-3);
152
+ }
153
+ }
154
+
155
+ .title {
156
+ @include mixins.font-clamp(2);
157
+ @include mixins.font(500, 18px, 24px);
158
+ }
159
+ }
160
+ }
161
+ }
162
+ }
163
+
164
+ .buttonWrapper {
165
+ @include mixins.flex($align: center, $justify: space-between, $gap: 16px);
166
+ max-width: 540px;
167
+ margin: 32px auto 0px;
168
+
169
+ button:first-of-type > span {
170
+ color: #ffffff;
171
+ }
172
+
173
+ & > button:last-of-type {
174
+ & > span {
175
+ color: var(--color-red-5);
176
+ }
177
+ &:hover {
178
+ background-color: var(--color-red-5);
179
+ & > span {
180
+ color: #ffffff;
181
+ }
182
+ }
183
+
184
+ &:active {
185
+ & > span {
186
+ color: var(--color-red-5);
187
+ }
188
+ background-color: #ffffff;
189
+ border: 1px solid var(--color-grey-7);
190
+ }
191
+ }
192
+ & > button {
193
+ flex: 1;
194
+ & > span {
195
+ font-weight: 600;
196
+ }
197
+ }
198
+
199
+ .modal {
200
+ max-width: 484px;
201
+ padding: 16px;
202
+
203
+ p {
204
+ padding: 16px 16px 24px;
205
+ }
206
+ }
207
+ }
208
+
209
+ .replaceModal {
210
+ button:first-of-type {
211
+ & > span {
212
+ color: var(--color-grey-3);
213
+ }
214
+ &:hover {
215
+ background-color: var(--color-grey-10);
216
+ }
217
+ }
218
+
219
+ button:last-of-type {
220
+ background-color: var(--color-blue-3);
221
+ & > span {
222
+ color: #ffffff;
223
+ }
224
+ &:hover {
225
+ background-color: var(--color-blue-1);
226
+ }
227
+ &:active {
228
+ background-color: #ffffff;
229
+ border: 1px solid var(--color-blue-3) !important;
230
+ & > span {
231
+ color: var(--color-blue-3);
232
+ }
233
+ }
234
+ }
235
+ }
236
+
237
+ .deleteModal {
238
+ button:first-of-type {
239
+ & > span {
240
+ color: var(--color-grey-3);
241
+ }
242
+ &:hover {
243
+ background-color: var(--color-grey-10);
244
+ }
245
+ }
246
+
247
+ button:last-of-type {
248
+ background-color: var(--color-red-5);
249
+ & > span {
250
+ color: #ffffff;
251
+ }
252
+ &:hover {
253
+ background-color: var(--color-red-6);
254
+ }
255
+ &:active {
256
+ background-color: #ffffff;
257
+ border: 1px solid var(--color-red-3) !important;
258
+ & > span {
259
+ color: var(--color-red-3);
260
+ }
261
+ }
262
+ .disabled {
263
+ background-color: var(--color-grey-5) !important;
264
+ & > span {
265
+ color: var(--color-grey-3) !important;
266
+ }
267
+ }
268
+ }
269
+ }
270
+
271
+ .deleteWrapper {
272
+ p {
273
+ padding: 0px 0px 16px !important;
274
+ }
275
+
276
+ input {
277
+ border: none;
278
+ outline: none;
279
+ width: 100%;
280
+ padding: 10px 20px;
281
+ background-color: var(--color-blue-10);
282
+ box-shadow: inset 0px 4px 4px rgba(0, 0, 0, 0.03);
283
+ border-radius: 16px;
284
+ border: 1px solid var(--color-grey-9);
285
+ }
286
+ }
287
+ }
288
+
289
+ .thumbnail {
290
+ width: 100%;
291
+
292
+ div > div > button {
293
+ background-color: transparent;
294
+ }
295
+
296
+ div > div > button > span {
297
+ color: var(--color-green-5);
298
+ }
299
+ }
300
+
301
+ .addToPlaylist {
302
+ [class~="switch"] {
303
+ width: 350px;
304
+ border-radius: 8px;
305
+ background-color: var(--color-grey-9);
306
+ & > div {
307
+ border-radius: 8px;
308
+ color: var(--color-grey-4);
309
+ &[class~="active"] {
310
+ font-weight: 700;
311
+ color: var(--color-blue-3);
312
+ }
313
+ }
314
+ }
315
+ }
316
+ }