@soul-refiner/design-system 0.0.10 → 0.0.12
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/custom.d.ts +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/{design-system.umd.cjs → index.umd.cjs} +1 -1
- package/dist/src/actions/Button/Button.module.scss +205 -0
- package/dist/src/actions/Button/Button.spec.js +56 -0
- package/dist/src/actions/Button/Button.tsx +143 -0
- package/dist/src/actions/Button/index.ts +1 -0
- package/dist/src/actions/Dropdown/Dropdown.module.scss +77 -0
- package/dist/src/actions/Dropdown/Dropdown.spec.js +149 -0
- package/dist/src/actions/Dropdown/Dropdown.tsx +224 -0
- package/dist/src/actions/Dropdown/index.ts +6 -0
- package/dist/src/actions/Dropzone/Dropzone.module.scss +48 -0
- package/dist/src/actions/Dropzone/Dropzone.spec.js +60 -0
- package/dist/src/actions/Dropzone/Dropzone.tsx +191 -0
- package/dist/src/actions/Dropzone/index.ts +1 -0
- package/dist/src/actions/Rate/Rate.module.scss +17 -0
- package/dist/src/actions/Rate/Rate.tsx +53 -0
- package/dist/src/actions/Rate/index.ts +1 -0
- package/dist/src/actions/Switch/Switch.module.scss +35 -0
- package/dist/src/actions/Switch/Switch.spec.js +31 -0
- package/dist/src/actions/Switch/Switch.tsx +34 -0
- package/dist/src/actions/Switch/index.ts +1 -0
- package/dist/src/actions/index.ts +5 -0
- package/dist/src/cards/CourseCard/CourseCard.module.scss +219 -0
- package/dist/src/cards/CourseCard/CourseCard.spec.js +60 -0
- package/dist/src/cards/CourseCard/CourseCard.tsx +145 -0
- package/dist/src/cards/CourseCard/index.ts +1 -0
- package/dist/src/cards/EpisodeCard/EpisodeCard.module.scss +69 -0
- package/dist/src/cards/EpisodeCard/EpisodeCard.tsx +53 -0
- package/dist/src/cards/EpisodeCard/index.ts +1 -0
- package/dist/src/cards/FeatureCard/FeatureCard.module.scss +116 -0
- package/dist/src/cards/FeatureCard/FeatureCard.spec.js +70 -0
- package/dist/src/cards/FeatureCard/FeatureCard.tsx +123 -0
- package/dist/src/cards/FeatureCard/index.ts +1 -0
- package/dist/src/cards/index.ts +3 -0
- package/dist/src/data/Bar/Bar.module.scss +105 -0
- package/dist/src/data/Bar/Bar.tsx +161 -0
- package/dist/src/data/Bar/index.ts +1 -0
- package/dist/src/data/Line/Line.module.scss +102 -0
- package/dist/src/data/Line/Line.tsx +162 -0
- package/dist/src/data/Line/index.ts +1 -0
- package/dist/src/data/Pie/Pie.module.scss +56 -0
- package/dist/src/data/Pie/Pie.spec.js +72 -0
- package/dist/src/data/Pie/Pie.tsx +111 -0
- package/dist/src/data/Pie/index.ts +1 -0
- package/dist/src/data/index.ts +3 -0
- package/dist/src/editor/Editor.module.scss +125 -0
- package/dist/src/editor/Editor.tsx +327 -0
- package/dist/src/editor/common/elements.ts +50 -0
- package/dist/src/editor/common/index.ts +2 -0
- package/dist/src/editor/common/marks.ts +27 -0
- package/dist/src/editor/components/MediaDrawer/MediaDrawer.module.scss +316 -0
- package/dist/src/editor/components/MediaDrawer/MediaDrawer.tsx +457 -0
- package/dist/src/editor/components/MediaDrawer/index.ts +1 -0
- package/dist/src/editor/components/index.ts +1 -0
- package/dist/src/editor/config/default.ts +213 -0
- package/dist/src/editor/config/index.ts +2 -0
- package/dist/src/editor/config/props.ts +9 -0
- package/dist/src/editor/index.ts +2 -0
- package/dist/src/editor/plateUI.ts +82 -0
- package/dist/src/editor/plugins/blocks.tsx +71 -0
- package/dist/src/editor/plugins/custom/assets/DefaultThumbnail.tsx +57 -0
- package/dist/src/editor/plugins/custom/assets/index.ts +1 -0
- package/dist/src/editor/plugins/custom/buttons.tsx +289 -0
- package/dist/src/editor/plugins/custom/example.tsx +64 -0
- package/dist/src/editor/plugins/custom/exitBreak.ts +41 -0
- package/dist/src/editor/plugins/custom/footnote.tsx +185 -0
- package/dist/src/editor/plugins/custom/index.ts +14 -0
- package/dist/src/editor/plugins/custom/paywall.tsx +156 -0
- package/dist/src/editor/plugins/custom/qa.tsx +390 -0
- package/dist/src/editor/plugins/custom/resetBlockType.ts +29 -0
- package/dist/src/editor/plugins/custom/selectOnBackspace.ts +7 -0
- package/dist/src/editor/plugins/custom/softBreak.ts +20 -0
- package/dist/src/editor/plugins/custom/styles/Button.module.scss +51 -0
- package/dist/src/editor/plugins/custom/styles/Footnote.module.scss +58 -0
- package/dist/src/editor/plugins/custom/styles/Paywall.module.scss +67 -0
- package/dist/src/editor/plugins/custom/styles/QA.module.scss +140 -0
- package/dist/src/editor/plugins/custom/styles/Video.module.scss +79 -0
- package/dist/src/editor/plugins/custom/video.tsx +163 -0
- package/dist/src/editor/plugins/index.ts +18 -0
- package/dist/src/editor/plugins/inline.ts +46 -0
- package/dist/src/editor/plugins/marks.ts +25 -0
- package/dist/src/editor/plugins/utils.ts +22 -0
- package/dist/src/feedback/Chip/Chip.module.scss +23 -0
- package/dist/src/feedback/Chip/Chip.tsx +58 -0
- package/dist/src/feedback/Chip/index.ts +1 -0
- package/dist/src/feedback/Loader/Loader.module.scss +18 -0
- package/dist/src/feedback/Loader/Loader.spec.js +18 -0
- package/dist/src/feedback/Loader/Loader.tsx +53 -0
- package/dist/src/feedback/Loader/index.ts +1 -0
- package/dist/src/feedback/ProgressBar/ProgressBar.module.scss +13 -0
- package/dist/src/feedback/ProgressBar/ProgressBar.tsx +32 -0
- package/dist/src/feedback/ProgressBar/index.ts +1 -0
- package/dist/src/feedback/Toast/Toast.module.scss +44 -0
- package/dist/src/feedback/Toast/Toast.tsx +76 -0
- package/dist/src/feedback/Toast/index.ts +1 -0
- package/dist/src/feedback/Tooltip/Tooltip.module.scss +47 -0
- package/dist/src/feedback/Tooltip/Tooltip.tsx +10 -0
- package/dist/src/feedback/Tooltip/index.ts +1 -0
- package/dist/src/feedback/index.ts +5 -0
- package/dist/src/global.d.ts +6 -0
- package/dist/src/iconography/Avatar/Avatar.module.scss +90 -0
- package/dist/src/iconography/Avatar/Avatar.spec.js +75 -0
- package/dist/src/iconography/Avatar/Avatar.tsx +96 -0
- package/dist/src/iconography/Avatar/DefaultIcon.svg +4 -0
- package/dist/src/iconography/Avatar/DefaultIcon.tsx +12 -0
- package/dist/src/iconography/Avatar/iconHelpers.tsx +186 -0
- package/dist/src/iconography/Avatar/index.ts +1 -0
- package/dist/src/iconography/ColoredIcon/ColoredIcon.module.scss +40 -0
- package/dist/src/iconography/ColoredIcon/ColoredIcon.tsx +30 -0
- package/dist/src/iconography/ColoredIcon/index.ts +5 -0
- package/dist/src/iconography/DevicePreview/DevicePreview.module.scss +143 -0
- package/dist/src/iconography/DevicePreview/DevicePreview.tsx +592 -0
- package/dist/src/iconography/DevicePreview/index.ts +1 -0
- package/dist/src/iconography/IconHeader/IconHeader.module.scss +42 -0
- package/dist/src/iconography/IconHeader/IconHeader.tsx +42 -0
- package/dist/src/iconography/IconHeader/index.ts +1 -0
- package/dist/src/iconography/StarRating/StarRating.tsx +99 -0
- package/dist/src/iconography/StarRating/index.ts +1 -0
- package/dist/src/iconography/index.ts +5 -0
- package/dist/src/implementations/BodyContent/BodyContent.module.scss +38 -0
- package/dist/src/implementations/BodyContent/BodyContent.tsx +78 -0
- package/dist/src/implementations/BodyContent/index.ts +2 -0
- package/dist/src/implementations/JoinGroupModal/JoinGroupModal.module.scss +83 -0
- package/dist/src/implementations/JoinGroupModal/JoinGroupModal.tsx +176 -0
- package/dist/src/implementations/JoinGroupModal/index.ts +1 -0
- package/dist/src/implementations/index.ts +2 -0
- package/dist/src/index.ts +149 -0
- package/dist/src/inputs/CalendarInput/CalendarInput.module.scss +38 -0
- package/dist/src/inputs/CalendarInput/CalendarInput.spec.js +19 -0
- package/dist/src/inputs/CalendarInput/CalendarInput.tsx +29 -0
- package/dist/src/inputs/CalendarInput/index.ts +1 -0
- package/dist/src/inputs/CheckboxInput/CheckboxInput.module.scss +23 -0
- package/dist/src/inputs/CheckboxInput/CheckboxInput.tsx +39 -0
- package/dist/src/inputs/CheckboxInput/index.ts +1 -0
- package/dist/src/inputs/FeedInput/FeedInput.module.scss +48 -0
- package/dist/src/inputs/FeedInput/FeedInput.spec.js +16 -0
- package/dist/src/inputs/FeedInput/FeedInput.tsx +197 -0
- package/dist/src/inputs/FeedInput/index.ts +1 -0
- package/dist/src/inputs/InboxInput/InboxInput.module.scss +48 -0
- package/dist/src/inputs/InboxInput/InboxInput.spec.js +19 -0
- package/dist/src/inputs/InboxInput/InboxInput.tsx +97 -0
- package/dist/src/inputs/InboxInput/index.ts +1 -0
- package/dist/src/inputs/PostInput/PostInput.module.scss +49 -0
- package/dist/src/inputs/PostInput/PostInput.spec.js +19 -0
- package/dist/src/inputs/PostInput/PostInput.tsx +54 -0
- package/dist/src/inputs/PostInput/index.ts +1 -0
- package/dist/src/inputs/RadioInput/RadioInput.module.scss +68 -0
- package/dist/src/inputs/RadioInput/RadioInput.tsx +55 -0
- package/dist/src/inputs/RadioInput/index.ts +1 -0
- package/dist/src/inputs/SearchInput/SearchInput.module.scss +40 -0
- package/dist/src/inputs/SearchInput/SearchInput.tsx +61 -0
- package/dist/src/inputs/SearchInput/index.ts +1 -0
- package/dist/src/inputs/SelectInput/SelectInput.module.scss +66 -0
- package/dist/src/inputs/SelectInput/SelectInput.tsx +145 -0
- package/dist/src/inputs/SelectInput/index.ts +1 -0
- package/dist/src/inputs/TagInput/TagInput.module.scss +75 -0
- package/dist/src/inputs/TagInput/TagInput.tsx +115 -0
- package/dist/src/inputs/TagInput/index.ts +1 -0
- package/dist/src/inputs/TextInput/TextInput.module.scss +35 -0
- package/dist/src/inputs/TextInput/TextInput.tsx +46 -0
- package/dist/src/inputs/TextInput/index.ts +1 -0
- package/dist/src/inputs/index.ts +10 -0
- package/dist/src/lists/ContactDetails/ContactDetails.module.scss +70 -0
- package/dist/src/lists/ContactDetails/ContactDetails.spec.js +69 -0
- package/dist/src/lists/ContactDetails/ContactDetails.tsx +185 -0
- package/dist/src/lists/ContactDetails/index.ts +1 -0
- package/dist/src/lists/index.ts +1 -0
- package/dist/src/navigation/Breadcrumbs/Breadcrumbs.module.scss +18 -0
- package/dist/src/navigation/Breadcrumbs/Breadcrumbs.spec.js +38 -0
- package/dist/src/navigation/Breadcrumbs/Breadcrumbs.tsx +43 -0
- package/dist/src/navigation/Breadcrumbs/index.ts +1 -0
- package/dist/src/navigation/Drawer/Drawer.module.scss +104 -0
- package/dist/src/navigation/Drawer/Drawer.tsx +177 -0
- package/dist/src/navigation/Drawer/index.ts +1 -0
- package/dist/src/navigation/EditorBar/EditorBar.module.scss +118 -0
- package/dist/src/navigation/EditorBar/EditorBar.tsx +416 -0
- package/dist/src/navigation/EditorBar/components/AlignmentDropdown/AlignmentDropdown.tsx +106 -0
- package/dist/src/navigation/EditorBar/components/AlignmentDropdown/index.ts +1 -0
- package/dist/src/navigation/EditorBar/components/ButtonModal/ButtonModal.module.scss +85 -0
- package/dist/src/navigation/EditorBar/components/ButtonModal/ButtonModal.tsx +314 -0
- package/dist/src/navigation/EditorBar/components/ButtonModal/assets/Comment.tsx +28 -0
- package/dist/src/navigation/EditorBar/components/ButtonModal/assets/GiftSubscription.tsx +28 -0
- package/dist/src/navigation/EditorBar/components/ButtonModal/assets/Link.tsx +28 -0
- package/dist/src/navigation/EditorBar/components/ButtonModal/assets/Share.tsx +28 -0
- package/dist/src/navigation/EditorBar/components/ButtonModal/assets/ShareCommunity.tsx +42 -0
- package/dist/src/navigation/EditorBar/components/ButtonModal/assets/Signup.tsx +68 -0
- package/dist/src/navigation/EditorBar/components/ButtonModal/assets/Special.tsx +24 -0
- package/dist/src/navigation/EditorBar/components/ButtonModal/assets/Subscribe.tsx +28 -0
- package/dist/src/navigation/EditorBar/components/ButtonModal/assets/index.ts +8 -0
- package/dist/src/navigation/EditorBar/components/ButtonModal/index.ts +1 -0
- package/dist/src/navigation/EditorBar/components/FontDropdown/FontDropdown.module.scss +16 -0
- package/dist/src/navigation/EditorBar/components/FontDropdown/FontDropdown.tsx +137 -0
- package/dist/src/navigation/EditorBar/components/FontDropdown/index.ts +1 -0
- package/dist/src/navigation/EditorBar/components/MoreDropdown/MoreDropdown.module.scss +43 -0
- package/dist/src/navigation/EditorBar/components/MoreDropdown/MoreDropdown.tsx +124 -0
- package/dist/src/navigation/EditorBar/components/MoreDropdown/index.ts +1 -0
- package/dist/src/navigation/EditorBar/components/OutlineDropdown/OutlineDropdown.module.scss +21 -0
- package/dist/src/navigation/EditorBar/components/OutlineDropdown/OutlineDropdown.tsx +37 -0
- package/dist/src/navigation/EditorBar/components/OutlineDropdown/index.ts +1 -0
- package/dist/src/navigation/EditorBar/components/TextTypeDropdown/TextTypeDropdown.module.scss +51 -0
- package/dist/src/navigation/EditorBar/components/TextTypeDropdown/TextTypeDropdown.tsx +80 -0
- package/dist/src/navigation/EditorBar/components/TextTypeDropdown/index.ts +1 -0
- package/dist/src/navigation/EditorBar/components/VideoModal/VideoModal.module.scss +150 -0
- package/dist/src/navigation/EditorBar/components/VideoModal/VideoModal.tsx +163 -0
- package/dist/src/navigation/EditorBar/components/VideoModal/index.ts +1 -0
- package/dist/src/navigation/EditorBar/components/index.ts +7 -0
- package/dist/src/navigation/EditorBar/index.ts +1 -0
- package/dist/src/navigation/MenuTabs/MenuTabs.module.scss +34 -0
- package/dist/src/navigation/MenuTabs/MenuTabs.spec.js +36 -0
- package/dist/src/navigation/MenuTabs/MenuTabs.tsx +52 -0
- package/dist/src/navigation/MenuTabs/index.ts +1 -0
- package/dist/src/navigation/Navigation/Navigation.module.scss +92 -0
- package/dist/src/navigation/Navigation/Navigation.spec.js +144 -0
- package/dist/src/navigation/Navigation/Navigation.tsx +111 -0
- package/dist/src/navigation/Navigation/SubNavigation.module.scss +255 -0
- package/dist/src/navigation/Navigation/SubNavigation.spec.js +112 -0
- package/dist/src/navigation/Navigation/SubNavigation.tsx +443 -0
- package/dist/src/navigation/Navigation/index.ts +15 -0
- package/dist/src/navigation/Pagination/Pagination.module.scss +49 -0
- package/dist/src/navigation/Pagination/Pagination.tsx +115 -0
- package/dist/src/navigation/Pagination/index.ts +1 -0
- package/dist/src/navigation/index.ts +21 -0
- package/dist/src/surfaces/Comment/Comment.module.scss +106 -0
- package/dist/src/surfaces/Comment/Comment.spec.js +105 -0
- package/dist/src/surfaces/Comment/Comment.tsx +157 -0
- package/dist/src/surfaces/Comment/index.ts +1 -0
- package/dist/src/surfaces/Faq/Faq.module.scss +91 -0
- package/dist/src/surfaces/Faq/Faq.spec.js +38 -0
- package/dist/src/surfaces/Faq/Faq.tsx +156 -0
- package/dist/src/surfaces/Faq/index.ts +1 -0
- package/dist/src/surfaces/Message/Message.module.scss +37 -0
- package/dist/src/surfaces/Message/Message.spec.js +47 -0
- package/dist/src/surfaces/Message/Message.tsx +54 -0
- package/dist/src/surfaces/Message/index.ts +1 -0
- package/dist/src/surfaces/Modal/Modal.module.scss +52 -0
- package/dist/src/surfaces/Modal/Modal.spec.js +38 -0
- package/dist/src/surfaces/Modal/Modal.tsx +131 -0
- package/dist/src/surfaces/Modal/index.ts +5 -0
- package/dist/src/surfaces/Plan/Plan.module.scss +79 -0
- package/dist/src/surfaces/Plan/Plan.tsx +75 -0
- package/dist/src/surfaces/Plan/index.ts +1 -0
- package/dist/src/surfaces/Post/Post.module.scss +46 -0
- package/dist/src/surfaces/Post/Post.spec.js +103 -0
- package/dist/src/surfaces/Post/Post.tsx +185 -0
- package/dist/src/surfaces/Post/index.ts +1 -0
- package/dist/src/surfaces/Post/postHelpers.ts +20 -0
- package/dist/src/surfaces/ProfileHeader/ProfileHeader.module.scss +202 -0
- package/dist/src/surfaces/ProfileHeader/ProfileHeader.tsx +103 -0
- package/dist/src/surfaces/ProfileHeader/index.ts +1 -0
- package/dist/src/surfaces/RatingsOverview/RatingsOverview.module.scss +54 -0
- package/dist/src/surfaces/RatingsOverview/RatingsOverview.tsx +69 -0
- package/dist/src/surfaces/RatingsOverview/index.ts +1 -0
- package/dist/src/surfaces/Review/Review.module.scss +73 -0
- package/dist/src/surfaces/Review/Review.tsx +88 -0
- package/dist/src/surfaces/Review/index.ts +1 -0
- package/dist/src/surfaces/index.ts +9 -0
- package/dist/src/tables/Filter/Filter.module.scss +34 -0
- package/dist/src/tables/Filter/Filter.tsx +30 -0
- package/dist/src/tables/Filter/index.ts +1 -0
- package/dist/src/tables/Table/Table.module.scss +126 -0
- package/dist/src/tables/Table/Table.spec.js +113 -0
- package/dist/src/tables/Table/Table.tsx +251 -0
- package/dist/src/tables/Table/index.ts +7 -0
- package/dist/src/tables/index.ts +7 -0
- package/package.json +7 -6
- /package/dist/{design-system.js → index.js} +0 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {
|
|
3
|
+
createPluginFactory,
|
|
4
|
+
findNode,
|
|
5
|
+
removeNodes,
|
|
6
|
+
useHotkeys,
|
|
7
|
+
useComposedRef,
|
|
8
|
+
useOnClickOutside,
|
|
9
|
+
} from "@udecode/plate";
|
|
10
|
+
import { ELEMENT_FOOTNOTE } from "../../common";
|
|
11
|
+
import { CloseThin, Footnote as FootnoteIcon } from "@soul-refiner/icons/src";
|
|
12
|
+
|
|
13
|
+
import { EditorContext } from "../../Editor";
|
|
14
|
+
|
|
15
|
+
import styles from "./styles/Footnote.module.scss";
|
|
16
|
+
|
|
17
|
+
type FootnoteProps = any;
|
|
18
|
+
|
|
19
|
+
export const Footnote = ({
|
|
20
|
+
attributes,
|
|
21
|
+
className,
|
|
22
|
+
children,
|
|
23
|
+
editor,
|
|
24
|
+
}: FootnoteProps) => {
|
|
25
|
+
const { ref: DONT_USE, ...htmlAttributes } = attributes;
|
|
26
|
+
const { handleFootnoteChange, handleFootnoteDelete } =
|
|
27
|
+
React.useContext(EditorContext);
|
|
28
|
+
const [open, setOpen] = React.useState(false);
|
|
29
|
+
const id = React.useRef<string>(
|
|
30
|
+
Math.round(Math.random() * 100000000).toString(36)
|
|
31
|
+
).current;
|
|
32
|
+
const text: string = children[0]?.props?.text?.text ?? "";
|
|
33
|
+
|
|
34
|
+
React.useEffect(() => {
|
|
35
|
+
if (text === "") handleFootnoteDelete(id);
|
|
36
|
+
else handleFootnoteChange(id, text);
|
|
37
|
+
}, [text, id]);
|
|
38
|
+
|
|
39
|
+
const toggleOpen = (event: React.MouseEvent) => {
|
|
40
|
+
event.stopPropagation();
|
|
41
|
+
if (open) {
|
|
42
|
+
handleClose();
|
|
43
|
+
} else {
|
|
44
|
+
setOpen(true);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const ref = useOnClickOutside(
|
|
49
|
+
() => {
|
|
50
|
+
setOpen(false);
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
disabled: !open,
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
const handleClose = (event?: React.KeyboardEvent) => {
|
|
58
|
+
event?.preventDefault();
|
|
59
|
+
event?.stopPropagation();
|
|
60
|
+
setOpen(false);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
useHotkeys(
|
|
64
|
+
"backspace",
|
|
65
|
+
((event: React.KeyboardEvent) => {
|
|
66
|
+
const currNode = findNode(editor, {
|
|
67
|
+
match: {
|
|
68
|
+
type: ELEMENT_FOOTNOTE,
|
|
69
|
+
},
|
|
70
|
+
at: editor.selection,
|
|
71
|
+
});
|
|
72
|
+
if (!currNode || open || text !== "") {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
removeNodes(editor, {
|
|
76
|
+
at: currNode![1],
|
|
77
|
+
});
|
|
78
|
+
}) as any,
|
|
79
|
+
{
|
|
80
|
+
enabled: true,
|
|
81
|
+
enableOnContentEditable: true,
|
|
82
|
+
enableOnTags: ["INPUT"],
|
|
83
|
+
},
|
|
84
|
+
[]
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
useHotkeys(
|
|
88
|
+
"enter",
|
|
89
|
+
((event: React.KeyboardEvent) => {
|
|
90
|
+
if (event.key === "Enter" && open) handleClose(event);
|
|
91
|
+
}) as any,
|
|
92
|
+
{
|
|
93
|
+
enabled: true,
|
|
94
|
+
enableOnContentEditable: true,
|
|
95
|
+
enableOnTags: ["INPUT"],
|
|
96
|
+
},
|
|
97
|
+
[]
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
useHotkeys(
|
|
101
|
+
"*",
|
|
102
|
+
((event: React.KeyboardEvent) => {
|
|
103
|
+
const currNode = findNode(editor, {
|
|
104
|
+
match: {
|
|
105
|
+
type: ELEMENT_FOOTNOTE,
|
|
106
|
+
},
|
|
107
|
+
at: editor.selection,
|
|
108
|
+
});
|
|
109
|
+
if (
|
|
110
|
+
children[0].props.text.text === "" &&
|
|
111
|
+
currNode &&
|
|
112
|
+
open &&
|
|
113
|
+
(event.key === "Backspace" || event.key === "Delete")
|
|
114
|
+
) {
|
|
115
|
+
removeNodes(editor, {
|
|
116
|
+
at: currNode![1],
|
|
117
|
+
});
|
|
118
|
+
handleFootnoteDelete(id);
|
|
119
|
+
}
|
|
120
|
+
}) as any,
|
|
121
|
+
{
|
|
122
|
+
enabled: true,
|
|
123
|
+
enableOnContentEditable: true,
|
|
124
|
+
enableOnTags: ["INPUT"],
|
|
125
|
+
},
|
|
126
|
+
[]
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
return (
|
|
130
|
+
<sup
|
|
131
|
+
className={`${styles.inline} ${className}`}
|
|
132
|
+
tabIndex={0}
|
|
133
|
+
ref={useComposedRef(ref)}
|
|
134
|
+
>
|
|
135
|
+
<span onClick={toggleOpen} contentEditable={false}>
|
|
136
|
+
{" "}
|
|
137
|
+
</span>
|
|
138
|
+
<div className={styles.floating} style={open ? {} : { display: "none" }}>
|
|
139
|
+
<FootnoteIcon fill="var(--color-grey-3)" iconSize={18} size={36} />
|
|
140
|
+
<p onKeyDown={handleClose}>{children}</p>
|
|
141
|
+
<CloseThin
|
|
142
|
+
fill="var(--color-grey-3)"
|
|
143
|
+
iconSize={12}
|
|
144
|
+
size={36}
|
|
145
|
+
onClick={() => setOpen(false)}
|
|
146
|
+
/>
|
|
147
|
+
</div>
|
|
148
|
+
</sup>
|
|
149
|
+
);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
export const createFootnotePlugin = createPluginFactory({
|
|
153
|
+
key: ELEMENT_FOOTNOTE,
|
|
154
|
+
type: ELEMENT_FOOTNOTE,
|
|
155
|
+
isElement: true,
|
|
156
|
+
isInline: true,
|
|
157
|
+
component: Footnote,
|
|
158
|
+
options: {
|
|
159
|
+
rangeBeforeOptions: {
|
|
160
|
+
matchString: " ",
|
|
161
|
+
skipInvalid: true,
|
|
162
|
+
afterMatch: true,
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
renderAfterEditable: () => {
|
|
166
|
+
const { footnotes } = React.useContext(EditorContext);
|
|
167
|
+
return (
|
|
168
|
+
<div className={styles.footnotesWrapper}>
|
|
169
|
+
{footnotes.map((footnote) => (
|
|
170
|
+
<p key={footnote.id}>
|
|
171
|
+
<span> </span>
|
|
172
|
+
<span>{footnote.text}</span>
|
|
173
|
+
</p>
|
|
174
|
+
))}
|
|
175
|
+
</div>
|
|
176
|
+
);
|
|
177
|
+
},
|
|
178
|
+
then: (editor) => ({
|
|
179
|
+
inject: {
|
|
180
|
+
props: {
|
|
181
|
+
classNames: ["footnote"],
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
}),
|
|
185
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { Button, createButtonsPlugin } from "./buttons";
|
|
2
|
+
export { ExampleElement, createExamplePlugin, } from "./example";
|
|
3
|
+
export {
|
|
4
|
+
Footnote,
|
|
5
|
+
createFootnotePlugin,
|
|
6
|
+
} from "./footnote";
|
|
7
|
+
export { Paywall, createPaywallPlugin } from "./paywall";
|
|
8
|
+
export { QA, createQAPlugin } from "./qa";
|
|
9
|
+
export { Video, createVideoPlugin } from "./video";
|
|
10
|
+
|
|
11
|
+
export { exitBreakPlugin } from "./exitBreak";
|
|
12
|
+
export { resetBlockTypePlugin } from "./resetBlockType";
|
|
13
|
+
export { selectOnBackspace } from "./selectOnBackspace";
|
|
14
|
+
export { softBreakPlugin } from "./softBreak";
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {
|
|
3
|
+
createPluginFactory,
|
|
4
|
+
getAboveNode,
|
|
5
|
+
isEditorReadOnly,
|
|
6
|
+
setNodes,
|
|
7
|
+
} from "@udecode/plate";
|
|
8
|
+
import {
|
|
9
|
+
COLORS,
|
|
10
|
+
ELEMENT_PAYWALL,
|
|
11
|
+
ELEMENT_H1,
|
|
12
|
+
ELEMENT_H2,
|
|
13
|
+
ELEMENT_H3,
|
|
14
|
+
ELEMENT_H4,
|
|
15
|
+
ELEMENT_H5,
|
|
16
|
+
ELEMENT_H6,
|
|
17
|
+
ELEMENT_PARAGRAPH,
|
|
18
|
+
} from "../../common";
|
|
19
|
+
|
|
20
|
+
import { Button } from "../../../actions";
|
|
21
|
+
import { EditorContext } from "../../Editor";
|
|
22
|
+
|
|
23
|
+
import styles from "./styles/Paywall.module.scss";
|
|
24
|
+
|
|
25
|
+
type PaywallProps = any;
|
|
26
|
+
|
|
27
|
+
export const Paywall = ({
|
|
28
|
+
attributes,
|
|
29
|
+
className,
|
|
30
|
+
children,
|
|
31
|
+
editor,
|
|
32
|
+
element,
|
|
33
|
+
}: PaywallProps) => {
|
|
34
|
+
const { user } = React.useContext(EditorContext);
|
|
35
|
+
const [state, setState] = React.useState("");
|
|
36
|
+
const { ref: DONT_USE, ...htmlAttributes } = attributes;
|
|
37
|
+
const { additionalText, color } = element;
|
|
38
|
+
|
|
39
|
+
const _children = React.Children.toArray(children);
|
|
40
|
+
const mainChildren = _children.filter(
|
|
41
|
+
(child) => React.isValidElement(child) && !child.props.text?.buttonText
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
let currAboveNode = getAboveNode(editor, {
|
|
45
|
+
at: editor.selection,
|
|
46
|
+
match: {
|
|
47
|
+
type: ELEMENT_PAYWALL,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const editable = !isEditorReadOnly(editor);
|
|
52
|
+
|
|
53
|
+
const handleColorChange = (color: string) => {
|
|
54
|
+
if (currAboveNode) {
|
|
55
|
+
setNodes(
|
|
56
|
+
editor,
|
|
57
|
+
{
|
|
58
|
+
color,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
at: currAboveNode ? currAboveNode[1] : undefined,
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const ColorMenu = () =>
|
|
68
|
+
!currAboveNode?.[1] ? null : (
|
|
69
|
+
<div className={styles.colorpicker} contentEditable={false}>
|
|
70
|
+
{COLORS.map((color) => (
|
|
71
|
+
<div
|
|
72
|
+
className={styles.color}
|
|
73
|
+
contentEditable={false}
|
|
74
|
+
key={color}
|
|
75
|
+
onClick={(event: React.MouseEvent) => {
|
|
76
|
+
event.stopPropagation();
|
|
77
|
+
handleColorChange(color);
|
|
78
|
+
}}
|
|
79
|
+
style={
|
|
80
|
+
{
|
|
81
|
+
"--option-color": color,
|
|
82
|
+
"--option-color-dark": color
|
|
83
|
+
? color.replace("5", "1")
|
|
84
|
+
: "var(--color-blue-1)",
|
|
85
|
+
} as React.CSSProperties
|
|
86
|
+
}
|
|
87
|
+
/>
|
|
88
|
+
))}
|
|
89
|
+
</div>
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<div
|
|
94
|
+
className={styles.wrapper}
|
|
95
|
+
style={
|
|
96
|
+
{
|
|
97
|
+
"--highlight-color": color ?? "var(--color-blue-5)",
|
|
98
|
+
"--bg-color": color ? color.replace("5", "1") : "var(--color-blue-1)",
|
|
99
|
+
} as React.CSSProperties
|
|
100
|
+
}
|
|
101
|
+
>
|
|
102
|
+
<ColorMenu />
|
|
103
|
+
<div className={styles.paywall}>
|
|
104
|
+
{user?.firstName && (
|
|
105
|
+
<p
|
|
106
|
+
contentEditable={false}
|
|
107
|
+
style={{ pointerEvents: "none", color: "#FFFFFF" }}
|
|
108
|
+
>
|
|
109
|
+
Hi {user.firstName},
|
|
110
|
+
</p>
|
|
111
|
+
)}
|
|
112
|
+
{mainChildren}
|
|
113
|
+
<p className={styles.switch} contentEditable={false}>
|
|
114
|
+
Already a subscriber? <a href="/logout">Switch accounts</a>
|
|
115
|
+
</p>
|
|
116
|
+
</div>
|
|
117
|
+
{editable && (
|
|
118
|
+
<div contentEditable={false} className={styles.below}>
|
|
119
|
+
<div contentEditable={false} className={styles.line} />
|
|
120
|
+
<Button
|
|
121
|
+
buttonType="secondary"
|
|
122
|
+
contentEditable={false}
|
|
123
|
+
disabled={true}
|
|
124
|
+
shape="rectangular"
|
|
125
|
+
>
|
|
126
|
+
Paid content below this line
|
|
127
|
+
</Button>
|
|
128
|
+
<div className={styles.line} />
|
|
129
|
+
</div>
|
|
130
|
+
)}
|
|
131
|
+
</div>
|
|
132
|
+
);
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export const createPaywallPlugin = createPluginFactory({
|
|
136
|
+
key: ELEMENT_PAYWALL,
|
|
137
|
+
type: ELEMENT_PAYWALL,
|
|
138
|
+
isElement: true,
|
|
139
|
+
component: Paywall,
|
|
140
|
+
then: (editor) => ({
|
|
141
|
+
inject: {
|
|
142
|
+
props: {
|
|
143
|
+
classNames: undefined,
|
|
144
|
+
validTypes: [
|
|
145
|
+
ELEMENT_PARAGRAPH,
|
|
146
|
+
ELEMENT_H1,
|
|
147
|
+
ELEMENT_H2,
|
|
148
|
+
ELEMENT_H3,
|
|
149
|
+
ELEMENT_H4,
|
|
150
|
+
ELEMENT_H5,
|
|
151
|
+
ELEMENT_H6,
|
|
152
|
+
],
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
}),
|
|
156
|
+
});
|