mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-06-05 17:14:40 -04:00
added markdown export (#627)
This commit is contained in:
parent
4984008aff
commit
9f7a106834
5 changed files with 79 additions and 9 deletions
|
@ -29,7 +29,7 @@ export const DocumentBar: React.FC<DocumentBarProps> = ({ title, noteContent })
|
|||
</div>
|
||||
<div className="ml-auto navbar-nav">
|
||||
<ImportMenu/>
|
||||
<ExportMenu/>
|
||||
<ExportMenu title={title} noteContent={noteContent}/>
|
||||
<EditorMenu noteTitle={title}/>
|
||||
<ConnectionIndicator/>
|
||||
</div>
|
||||
|
|
|
@ -3,8 +3,14 @@ import { Dropdown } from 'react-bootstrap'
|
|||
import { Trans, useTranslation } from 'react-i18next'
|
||||
import links from '../../../../links.json'
|
||||
import { ForkAwesomeIcon } from '../../../common/fork-awesome/fork-awesome-icon'
|
||||
import { MarkdownExportDropdownItem } from './export/markdown'
|
||||
|
||||
const ExportMenu: React.FC = () => {
|
||||
export interface ExportMenuProps {
|
||||
title: string
|
||||
noteContent: string
|
||||
}
|
||||
|
||||
export const ExportMenu: React.FC<ExportMenuProps> = ({ title, noteContent }) => {
|
||||
useTranslation()
|
||||
return (
|
||||
<Dropdown className='small mx-1' alignRight={true}>
|
||||
|
@ -34,10 +40,10 @@ const ExportMenu: React.FC = () => {
|
|||
<Dropdown.Header>
|
||||
<Trans i18nKey='editor.documentBar.download'/>
|
||||
</Dropdown.Header>
|
||||
<Dropdown.Item className='small'>
|
||||
<ForkAwesomeIcon icon='file-text' className={'mx-2'}/>
|
||||
Markdown
|
||||
</Dropdown.Item>
|
||||
<MarkdownExportDropdownItem
|
||||
title={title}
|
||||
noteContent={noteContent}
|
||||
/>
|
||||
<Dropdown.Item className='small'>
|
||||
<ForkAwesomeIcon icon='file-code-o' className={'mx-2'}/>
|
||||
HTML
|
||||
|
@ -61,5 +67,3 @@ const ExportMenu: React.FC = () => {
|
|||
</Dropdown>
|
||||
)
|
||||
}
|
||||
|
||||
export { ExportMenu }
|
||||
|
|
18
src/components/editor/document-bar/menus/export/markdown.tsx
Normal file
18
src/components/editor/document-bar/menus/export/markdown.tsx
Normal file
|
@ -0,0 +1,18 @@
|
|||
import React from 'react'
|
||||
import { Dropdown } from 'react-bootstrap'
|
||||
import { download } from '../../../../common/download/download'
|
||||
import { ForkAwesomeIcon } from '../../../../common/fork-awesome/fork-awesome-icon'
|
||||
|
||||
export interface MarkdownExportDropdownItemProps {
|
||||
title: string
|
||||
noteContent: string
|
||||
}
|
||||
|
||||
export const MarkdownExportDropdownItem: React.FC<MarkdownExportDropdownItemProps> = ({ title, noteContent }) => {
|
||||
return (
|
||||
<Dropdown.Item className='small' onClick={() => download(noteContent, `${title}.md`, 'text/markdown')}>
|
||||
<ForkAwesomeIcon icon='file-text' className={'mx-2'}/>
|
||||
Markdown
|
||||
</Dropdown.Item>
|
||||
)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue