Added doc preview
This commit is contained in:
parent
8dcc1c0336
commit
586282d7fa
@ -13,7 +13,8 @@ interface BackstoryTextFieldProps {
|
|||||||
value?: string;
|
value?: string;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
placeholder: string;
|
placeholder: string;
|
||||||
onEnter: (value: string) => void;
|
onEnter?: (value: string) => void;
|
||||||
|
onChange?: (value: string) => void;
|
||||||
style?: CSSProperties;
|
style?: CSSProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,6 +24,7 @@ const BackstoryTextField = React.forwardRef<BackstoryTextFieldRef, BackstoryText
|
|||||||
disabled = false,
|
disabled = false,
|
||||||
placeholder,
|
placeholder,
|
||||||
onEnter,
|
onEnter,
|
||||||
|
onChange,
|
||||||
style,
|
style,
|
||||||
} = props;
|
} = props;
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
@ -82,7 +84,7 @@ const BackstoryTextField = React.forwardRef<BackstoryTextFieldRef, BackstoryText
|
|||||||
const handleKeyDown = (event: KeyboardEvent<HTMLTextAreaElement>) => {
|
const handleKeyDown = (event: KeyboardEvent<HTMLTextAreaElement>) => {
|
||||||
if (event.key === 'Enter' && !event.shiftKey) {
|
if (event.key === 'Enter' && !event.shiftKey) {
|
||||||
event.preventDefault(); // Prevent newline
|
event.preventDefault(); // Prevent newline
|
||||||
onEnter(editValue);
|
onEnter && onEnter(editValue);
|
||||||
setEditValue(''); // Clear textarea
|
setEditValue(''); // Clear textarea
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -95,7 +97,7 @@ const BackstoryTextField = React.forwardRef<BackstoryTextFieldRef, BackstoryText
|
|||||||
resize: 'none',
|
resize: 'none',
|
||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
boxSizing: 'border-box',
|
boxSizing: 'border-box',
|
||||||
minHeight: 'calc(1.5rem + 28px)', // lineHeight + padding
|
// minHeight: 'calc(1.5rem + 28px)', // lineHeight + padding
|
||||||
lineHeight: '1.5',
|
lineHeight: '1.5',
|
||||||
borderRadius: '4px',
|
borderRadius: '4px',
|
||||||
fontSize: '16px',
|
fontSize: '16px',
|
||||||
@ -112,7 +114,7 @@ const BackstoryTextField = React.forwardRef<BackstoryTextFieldRef, BackstoryText
|
|||||||
value={editValue}
|
value={editValue}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
onChange={(e) => setEditValue(e.target.value)}
|
onChange={(e) => { setEditValue(e.target.value); onChange && onChange(e.target.value); }}
|
||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
style={fullStyle}
|
style={fullStyle}
|
||||||
/>
|
/>
|
||||||
|
@ -23,7 +23,9 @@ import {
|
|||||||
Dialog,
|
Dialog,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
DialogContent,
|
DialogContent,
|
||||||
DialogActions
|
DialogActions,
|
||||||
|
Tabs,
|
||||||
|
Tab
|
||||||
} from '@mui/material';
|
} from '@mui/material';
|
||||||
import {
|
import {
|
||||||
Delete as DeleteIcon,
|
Delete as DeleteIcon,
|
||||||
@ -37,10 +39,13 @@ import {
|
|||||||
Visibility as VisibilityIcon,
|
Visibility as VisibilityIcon,
|
||||||
VisibilityOff as VisibilityOffIcon
|
VisibilityOff as VisibilityOffIcon
|
||||||
} from '@mui/icons-material';
|
} from '@mui/icons-material';
|
||||||
|
import PreviewIcon from '@mui/icons-material/Preview';
|
||||||
|
import EditDocumentIcon from '@mui/icons-material/EditDocument';
|
||||||
import { useAuth } from 'hooks/AuthContext';
|
import { useAuth } from 'hooks/AuthContext';
|
||||||
import { useAppState } from 'hooks/GlobalContext';
|
import { useAppState } from 'hooks/GlobalContext';
|
||||||
import { StyledMarkdown } from 'components/StyledMarkdown';
|
import { StyledMarkdown } from 'components/StyledMarkdown';
|
||||||
import { Resume } from 'types/types';
|
import { Resume } from 'types/types';
|
||||||
|
import { BackstoryTextField } from 'components/BackstoryTextField';
|
||||||
|
|
||||||
interface ResumeInfoProps {
|
interface ResumeInfoProps {
|
||||||
resume: Resume;
|
resume: Resume;
|
||||||
@ -71,6 +76,7 @@ const ResumeInfo: React.FC<ResumeInfoProps> = (props: ResumeInfoProps) => {
|
|||||||
const [editContent, setEditContent] = useState<string>('');
|
const [editContent, setEditContent] = useState<string>('');
|
||||||
const [saving, setSaving] = useState<boolean>(false);
|
const [saving, setSaving] = useState<boolean>(false);
|
||||||
const contentRef = useRef<HTMLDivElement>(null);
|
const contentRef = useRef<HTMLDivElement>(null);
|
||||||
|
const [tabValue, setTabValue] = useState("markdown");
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (resume && resume.id !== activeResume?.id) {
|
if (resume && resume.id !== activeResume?.id) {
|
||||||
@ -137,6 +143,10 @@ const ResumeInfo: React.FC<ResumeInfoProps> = (props: ResumeInfoProps) => {
|
|||||||
}).format(date);
|
}).format(date);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleTabChange = (event: React.SyntheticEvent, newValue: string) => {
|
||||||
|
setTabValue(newValue);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
@ -334,7 +344,7 @@ const ResumeInfo: React.FC<ResumeInfoProps> = (props: ResumeInfoProps) => {
|
|||||||
onClose={() => setEditDialogOpen(false)}
|
onClose={() => setEditDialogOpen(false)}
|
||||||
maxWidth="lg"
|
maxWidth="lg"
|
||||||
fullWidth
|
fullWidth
|
||||||
fullScreen={isMobile}
|
fullScreen={true}
|
||||||
>
|
>
|
||||||
<DialogTitle>
|
<DialogTitle>
|
||||||
Edit Resume Content
|
Edit Resume Content
|
||||||
@ -342,23 +352,61 @@ const ResumeInfo: React.FC<ResumeInfoProps> = (props: ResumeInfoProps) => {
|
|||||||
Resume for {activeResume.candidate?.fullName || activeResume.candidateId}
|
Resume for {activeResume.candidate?.fullName || activeResume.candidateId}
|
||||||
</Typography>
|
</Typography>
|
||||||
</DialogTitle>
|
</DialogTitle>
|
||||||
<DialogContent>
|
<DialogContent sx={{ position: "relative", display: "flex", flexDirection: "column", height: "100%" }}>
|
||||||
<TextField
|
<Tabs value={tabValue} onChange={handleTabChange} centered>
|
||||||
multiline
|
<Tab value="markdown" icon={<EditDocumentIcon />} label="Markdown" />
|
||||||
fullWidth
|
<Tab value="preview" icon={<PreviewIcon />} label="Preview" />
|
||||||
rows={20}
|
</Tabs>
|
||||||
value={editContent}
|
<Box sx={{
|
||||||
onChange={(e) => setEditContent(e.target.value)}
|
display: "flex", flexDirection: "column",
|
||||||
variant="outlined"
|
height: "100%", /* Restrict to main-container's height */
|
||||||
sx={{
|
width: "100%",
|
||||||
mt: 1,
|
minHeight: 0,/* Prevent flex overflow */
|
||||||
'& .MuiInputBase-input': {
|
//maxHeight: "min-content",
|
||||||
fontFamily: 'monospace',
|
"& > *:not(.Scrollable)": {
|
||||||
fontSize: '0.875rem'
|
flexShrink: 0, /* Prevent shrinking */
|
||||||
}
|
},
|
||||||
}}
|
position: "relative",
|
||||||
placeholder="Enter resume content..."
|
border: "2px solid purple",
|
||||||
/>
|
}}>
|
||||||
|
|
||||||
|
{tabValue === "markdown" &&
|
||||||
|
<BackstoryTextField
|
||||||
|
value={editContent}
|
||||||
|
onChange={(value) => setEditContent(value)}
|
||||||
|
style={{
|
||||||
|
position: "relative",
|
||||||
|
// maxHeight: "100%",
|
||||||
|
height: "100%",
|
||||||
|
width: "100%",
|
||||||
|
display: "flex",
|
||||||
|
minHeight: "100%",
|
||||||
|
|
||||||
|
flexGrow: 1,
|
||||||
|
flex: 1, /* Take remaining space in some-container */
|
||||||
|
overflowY: "auto", /* Scroll if content overflows */
|
||||||
|
}}
|
||||||
|
placeholder="Enter resume content..."
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
{tabValue === "preview" && <>
|
||||||
|
<StyledMarkdown
|
||||||
|
sx={{
|
||||||
|
p: 2,
|
||||||
|
position: "relative",
|
||||||
|
maxHeight: "100%",
|
||||||
|
width: "100%",
|
||||||
|
display: "flex",
|
||||||
|
flexGrow: 1,
|
||||||
|
flex: 1, /* Take remaining space in some-container */
|
||||||
|
overflowY: "auto", /* Scroll if content overflows */
|
||||||
|
}}
|
||||||
|
|
||||||
|
content={editContent} />
|
||||||
|
<Box sx={{ pb: 2 }}></Box></>
|
||||||
|
}
|
||||||
|
</Box>
|
||||||
|
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
<DialogActions>
|
<DialogActions>
|
||||||
<Button onClick={() => setEditDialogOpen(false)}>
|
<Button onClick={() => setEditDialogOpen(false)}>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user