Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | 117x 60x 411x 117x 60x | import { Editor, EditorProps } from "react-draft-wysiwyg-next";
import { styled, Box } from "@mui/material";
type ReadOnlyEditorProps = EditorProps & StyledEditorProps;
export function ReadOnlyEditor({
isPaymentCard = false,
scrollTop = 0,
...props
}: ReadOnlyEditorProps) {
return (
<StyledEditor
isPaymentCard={isPaymentCard}
scrollTop={scrollTop}
>
<Editor
editorClassName="editorClassName"
readOnly
toolbarHidden
{...props}
/>
</StyledEditor>
);
}
type StyledEditorProps = {
isPaymentCard?: boolean;
scrollTop?: number;
}
const StyledEditor = styled(Box, {
shouldForwardProp: (prop) =>
prop !== "isPaymentCard" &&
prop !== "scrollTop"
})(({ isPaymentCard, scrollTop }: StyledEditorProps) => ({
"& .editorClassName": {
overflow: "hidden",
wordBreak: "break-word",
position: "relative",
...(isPaymentCard && {
"&::before": {
content: '""',
width: "100%",
height: "102px",
position: "absolute",
zIndex: 10,
left: 0,
top: 0,
background:
"linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, #FFFFFF 100%)",
"@media (max-width: 600px)": {
background:
"linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, #FFFFFF 65%)",
},
},
}),
...(scrollTop && {
"&::before": {
...overlayStyle,
display: scrollTop >= 160 ? "block" : "none",
top: scrollTop - 184,
},
}),
},
}));
const overlayStyle = {
content: '""',
width: "100%",
height: "77px",
position: "absolute",
left: 0,
zIndex: 10,
background:
"linear-gradient(180deg, #FFFFFF 19.27%, rgba(255, 255, 255, 0) 100%)",
} |