-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a111ba5
commit 7a2c23e
Showing
9 changed files
with
47 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 0 additions & 52 deletions
52
src/components/interactive-builder/markdown-question.component.tsx
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...lder/modals/question/question-form/rendering-types/inputs/markdown/markdown.component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React from 'react'; | ||
import ReactMde from 'react-mde'; | ||
import ReactMarkdown from 'react-markdown'; | ||
import type { ComponentProps } from '@types'; | ||
import styles from './markdown.scss'; | ||
|
||
const MarkdownQuestion: React.FC<ComponentProps> = ({ formField, setFormField }) => { | ||
const [selectedTab, setSelectedTab] = React.useState<'write' | 'preview'>('write'); | ||
|
||
const handleEditorChange = (newValue: string) => { | ||
const updatedFormField = { ...formField, value: newValue }; | ||
setFormField(updatedFormField); | ||
}; | ||
|
||
const handleTabChange = () => { | ||
setSelectedTab((prevTab) => (prevTab === 'write' ? 'preview' : 'write')); | ||
}; | ||
|
||
return ( | ||
<div className={styles.container}> | ||
<ReactMde | ||
value={formField.value} | ||
onChange={handleEditorChange} | ||
selectedTab={selectedTab} | ||
onTabChange={handleTabChange} | ||
toolbarCommands={[['bold', 'italic']]} | ||
generateMarkdownPreview={(markdown) => | ||
Promise.resolve(<ReactMarkdown children={Array.isArray(markdown) ? markdown.join('\n') : markdown} />) | ||
} | ||
childProps={{ | ||
writeButton: { | ||
tabIndex: -1, | ||
}, | ||
}} | ||
loadingPreview="loading preview..." | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default MarkdownQuestion; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters