mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 01:36:22 +00:00
Add structure for exporting PDFs
This commit is contained in:
@@ -205,6 +205,7 @@ export default class MarkdownPreview extends React.Component {
|
|||||||
this.saveAsTextHandler = () => this.handleSaveAsText()
|
this.saveAsTextHandler = () => this.handleSaveAsText()
|
||||||
this.saveAsMdHandler = () => this.handleSaveAsMd()
|
this.saveAsMdHandler = () => this.handleSaveAsMd()
|
||||||
this.saveAsHtmlHandler = () => this.handleSaveAsHtml()
|
this.saveAsHtmlHandler = () => this.handleSaveAsHtml()
|
||||||
|
this.saveAsPdfHandler = () => this.handleSaveAsPdf()
|
||||||
this.printHandler = () => this.handlePrint()
|
this.printHandler = () => this.handlePrint()
|
||||||
|
|
||||||
this.linkClickHandler = this.handlelinkClick.bind(this)
|
this.linkClickHandler = this.handlelinkClick.bind(this)
|
||||||
@@ -349,6 +350,12 @@ export default class MarkdownPreview extends React.Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleSaveAsPdf () {
|
||||||
|
this.exportAsDocument('pdf', (noteContent, exportTasks) => {
|
||||||
|
// Return pdf source
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
handlePrint () {
|
handlePrint () {
|
||||||
this.refs.root.contentWindow.print()
|
this.refs.root.contentWindow.print()
|
||||||
}
|
}
|
||||||
@@ -460,6 +467,7 @@ export default class MarkdownPreview extends React.Component {
|
|||||||
eventEmitter.on('export:save-text', this.saveAsTextHandler)
|
eventEmitter.on('export:save-text', this.saveAsTextHandler)
|
||||||
eventEmitter.on('export:save-md', this.saveAsMdHandler)
|
eventEmitter.on('export:save-md', this.saveAsMdHandler)
|
||||||
eventEmitter.on('export:save-html', this.saveAsHtmlHandler)
|
eventEmitter.on('export:save-html', this.saveAsHtmlHandler)
|
||||||
|
eventEmitter.on('export:save-pdf', this.saveAsPdfHandler)
|
||||||
eventEmitter.on('print', this.printHandler)
|
eventEmitter.on('print', this.printHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -495,6 +503,7 @@ export default class MarkdownPreview extends React.Component {
|
|||||||
eventEmitter.off('export:save-text', this.saveAsTextHandler)
|
eventEmitter.off('export:save-text', this.saveAsTextHandler)
|
||||||
eventEmitter.off('export:save-md', this.saveAsMdHandler)
|
eventEmitter.off('export:save-md', this.saveAsMdHandler)
|
||||||
eventEmitter.off('export:save-html', this.saveAsHtmlHandler)
|
eventEmitter.off('export:save-html', this.saveAsHtmlHandler)
|
||||||
|
eventEmitter.off('export:save-pdf', this.saveAsPdfHandler)
|
||||||
eventEmitter.off('print', this.printHandler)
|
eventEmitter.off('print', this.printHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class InfoPanel extends React.Component {
|
|||||||
|
|
||||||
render () {
|
render () {
|
||||||
const {
|
const {
|
||||||
storageName, folderName, noteLink, updatedAt, createdAt, exportAsMd, exportAsTxt, exportAsHtml, wordCount, letterCount, type, print
|
storageName, folderName, noteLink, updatedAt, createdAt, exportAsMd, exportAsTxt, exportAsHtml, exportAsPdf, wordCount, letterCount, type, print
|
||||||
} = this.props
|
} = this.props
|
||||||
return (
|
return (
|
||||||
<div className='infoPanel' styleName='control-infoButton-panel' style={{display: 'none'}}>
|
<div className='infoPanel' styleName='control-infoButton-panel' style={{display: 'none'}}>
|
||||||
@@ -85,6 +85,11 @@ class InfoPanel extends React.Component {
|
|||||||
<p>{i18n.__('.html')}</p>
|
<p>{i18n.__('.html')}</p>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
<button styleName='export--enable' onClick={(e) => exportAsPdf(e, 'export-pdf')}>
|
||||||
|
<i className='fa fa-file-pdf-o' />
|
||||||
|
<p>{i18n.__('.pdf')}</p>
|
||||||
|
</button>
|
||||||
|
|
||||||
<button styleName='export--enable' onClick={(e) => print(e, 'print')}>
|
<button styleName='export--enable' onClick={(e) => print(e, 'print')}>
|
||||||
<i className='fa fa-print' />
|
<i className='fa fa-print' />
|
||||||
<p>{i18n.__('Print')}</p>
|
<p>{i18n.__('Print')}</p>
|
||||||
@@ -104,6 +109,7 @@ InfoPanel.propTypes = {
|
|||||||
exportAsMd: PropTypes.func.isRequired,
|
exportAsMd: PropTypes.func.isRequired,
|
||||||
exportAsTxt: PropTypes.func.isRequired,
|
exportAsTxt: PropTypes.func.isRequired,
|
||||||
exportAsHtml: PropTypes.func.isRequired,
|
exportAsHtml: PropTypes.func.isRequired,
|
||||||
|
exportAsPdf: PropTypes.func.isRequired,
|
||||||
wordCount: PropTypes.number,
|
wordCount: PropTypes.number,
|
||||||
letterCount: PropTypes.number,
|
letterCount: PropTypes.number,
|
||||||
type: PropTypes.string.isRequired,
|
type: PropTypes.string.isRequired,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import styles from './InfoPanel.styl'
|
|||||||
import i18n from 'browser/lib/i18n'
|
import i18n from 'browser/lib/i18n'
|
||||||
|
|
||||||
const InfoPanelTrashed = ({
|
const InfoPanelTrashed = ({
|
||||||
storageName, folderName, updatedAt, createdAt, exportAsMd, exportAsTxt, exportAsHtml
|
storageName, folderName, updatedAt, createdAt, exportAsMd, exportAsTxt, exportAsHtml, exportAsPdf
|
||||||
}) => (
|
}) => (
|
||||||
<div className='infoPanel' styleName='control-infoButton-panel-trash' style={{display: 'none'}}>
|
<div className='infoPanel' styleName='control-infoButton-panel-trash' style={{display: 'none'}}>
|
||||||
<div>
|
<div>
|
||||||
@@ -46,7 +46,7 @@ const InfoPanelTrashed = ({
|
|||||||
<p>.html</p>
|
<p>.html</p>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button styleName='export--unable'>
|
<button styleName='export--enable' onClick={(e) => exportAsPdf(e, 'export-pdf')}>
|
||||||
<i className='fa fa-file-pdf-o' />
|
<i className='fa fa-file-pdf-o' />
|
||||||
<p>.pdf</p>
|
<p>.pdf</p>
|
||||||
</button>
|
</button>
|
||||||
@@ -61,7 +61,8 @@ InfoPanelTrashed.propTypes = {
|
|||||||
createdAt: PropTypes.string.isRequired,
|
createdAt: PropTypes.string.isRequired,
|
||||||
exportAsMd: PropTypes.func.isRequired,
|
exportAsMd: PropTypes.func.isRequired,
|
||||||
exportAsTxt: PropTypes.func.isRequired,
|
exportAsTxt: PropTypes.func.isRequired,
|
||||||
exportAsHtml: PropTypes.func.isRequired
|
exportAsHtml: PropTypes.func.isRequired,
|
||||||
|
exportAsPdf: PropTypes.func.isRequired
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CSSModules(InfoPanelTrashed, styles)
|
export default CSSModules(InfoPanelTrashed, styles)
|
||||||
|
|||||||
@@ -190,6 +190,10 @@ class MarkdownNoteDetail extends React.Component {
|
|||||||
ee.emit('export:save-html')
|
ee.emit('export:save-html')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exportAsPdf () {
|
||||||
|
ee.emit('export:save-pdf')
|
||||||
|
}
|
||||||
|
|
||||||
handleKeyDown (e) {
|
handleKeyDown (e) {
|
||||||
switch (e.keyCode) {
|
switch (e.keyCode) {
|
||||||
// tab key
|
// tab key
|
||||||
@@ -411,6 +415,7 @@ class MarkdownNoteDetail extends React.Component {
|
|||||||
exportAsHtml={this.exportAsHtml}
|
exportAsHtml={this.exportAsHtml}
|
||||||
exportAsMd={this.exportAsMd}
|
exportAsMd={this.exportAsMd}
|
||||||
exportAsTxt={this.exportAsTxt}
|
exportAsTxt={this.exportAsTxt}
|
||||||
|
exportAsPdf={this.exportAsPdf}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -476,6 +481,7 @@ class MarkdownNoteDetail extends React.Component {
|
|||||||
exportAsMd={this.exportAsMd}
|
exportAsMd={this.exportAsMd}
|
||||||
exportAsTxt={this.exportAsTxt}
|
exportAsTxt={this.exportAsTxt}
|
||||||
exportAsHtml={this.exportAsHtml}
|
exportAsHtml={this.exportAsHtml}
|
||||||
|
exportAsPdf={this.exportAsPdf}
|
||||||
wordCount={note.content.split(' ').length}
|
wordCount={note.content.split(' ').length}
|
||||||
letterCount={note.content.replace(/\r?\n/g, '').length}
|
letterCount={note.content.replace(/\r?\n/g, '').length}
|
||||||
type={note.type}
|
type={note.type}
|
||||||
|
|||||||
@@ -500,6 +500,7 @@ class NoteList extends React.Component {
|
|||||||
'export-txt': 'Text export',
|
'export-txt': 'Text export',
|
||||||
'export-md': 'Markdown export',
|
'export-md': 'Markdown export',
|
||||||
'export-html': 'HTML export',
|
'export-html': 'HTML export',
|
||||||
|
'export-pdf': 'PDF export',
|
||||||
'print': 'Print'
|
'print': 'Print'
|
||||||
})[msg]
|
})[msg]
|
||||||
|
|
||||||
|
|||||||
@@ -116,6 +116,13 @@ const file = {
|
|||||||
mainWindow.webContents.send('list:isMarkdownNote', 'export-html')
|
mainWindow.webContents.send('list:isMarkdownNote', 'export-html')
|
||||||
mainWindow.webContents.send('export:save-html')
|
mainWindow.webContents.send('export:save-html')
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'PDF (.pdf)',
|
||||||
|
click () {
|
||||||
|
mainWindow.webContents.send('list:isMarkdownNote', 'export-pdf')
|
||||||
|
mainWindow.webContents.send('export:save-pdf')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
".md": ".md",
|
".md": ".md",
|
||||||
".txt": ".txt",
|
".txt": ".txt",
|
||||||
".html": ".html",
|
".html": ".html",
|
||||||
|
".pdf": ".pdf",
|
||||||
"Print": "Print",
|
"Print": "Print",
|
||||||
"Your preferences for Boostnote": "Your preferences for Boostnote",
|
"Your preferences for Boostnote": "Your preferences for Boostnote",
|
||||||
"Storage Locations": "Storage Locations",
|
"Storage Locations": "Storage Locations",
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
".md": ".md",
|
".md": ".md",
|
||||||
".txt": ".txt",
|
".txt": ".txt",
|
||||||
".html": ".html",
|
".html": ".html",
|
||||||
|
".pdf": ".pdf",
|
||||||
"Print": "Drucken",
|
"Print": "Drucken",
|
||||||
"Your preferences for Boostnote": "Boostnote Einstellungen",
|
"Your preferences for Boostnote": "Boostnote Einstellungen",
|
||||||
"Storage Locations": "Speicherverwaltung",
|
"Storage Locations": "Speicherverwaltung",
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
".md": ".md",
|
".md": ".md",
|
||||||
".txt": ".txt",
|
".txt": ".txt",
|
||||||
".html": ".html",
|
".html": ".html",
|
||||||
|
".pdf": ".pdf",
|
||||||
"Print": "Print",
|
"Print": "Print",
|
||||||
"Your preferences for Boostnote": "Your preferences for Boostnote",
|
"Your preferences for Boostnote": "Your preferences for Boostnote",
|
||||||
"Help": "Help",
|
"Help": "Help",
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
".md": ".md",
|
".md": ".md",
|
||||||
".txt": ".txt",
|
".txt": ".txt",
|
||||||
".html": ".html",
|
".html": ".html",
|
||||||
|
".pdf": ".pdf",
|
||||||
"Print": "Imprimir",
|
"Print": "Imprimir",
|
||||||
"Your preferences for Boostnote": "Tus preferencias para Boostnote",
|
"Your preferences for Boostnote": "Tus preferencias para Boostnote",
|
||||||
"Storage Locations": "Almacenamientos",
|
"Storage Locations": "Almacenamientos",
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
".md": ".md",
|
".md": ".md",
|
||||||
".txt": ".txt",
|
".txt": ".txt",
|
||||||
".html": ".html",
|
".html": ".html",
|
||||||
|
".pdf": ".pdf",
|
||||||
"Print": "پرینت",
|
"Print": "پرینت",
|
||||||
"Your preferences for Boostnote": "تنظیمات شما برای boostnote",
|
"Your preferences for Boostnote": "تنظیمات شما برای boostnote",
|
||||||
"Storage Locations": "ذخیره سازی",
|
"Storage Locations": "ذخیره سازی",
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
".md": ".md",
|
".md": ".md",
|
||||||
".txt": ".txt",
|
".txt": ".txt",
|
||||||
".html": ".html",
|
".html": ".html",
|
||||||
|
".pdf": ".pdf",
|
||||||
"Print": "Imprimer",
|
"Print": "Imprimer",
|
||||||
"Your preferences for Boostnote": "Vos préférences pour Boostnote",
|
"Your preferences for Boostnote": "Vos préférences pour Boostnote",
|
||||||
"Storage Locations": "Stockages",
|
"Storage Locations": "Stockages",
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
".md": ".md",
|
".md": ".md",
|
||||||
".txt": ".txt",
|
".txt": ".txt",
|
||||||
".html": ".html",
|
".html": ".html",
|
||||||
|
".pdf": ".pdf",
|
||||||
"Print": "Nyomtatás",
|
"Print": "Nyomtatás",
|
||||||
"Your preferences for Boostnote": "Boostnote beállításaid",
|
"Your preferences for Boostnote": "Boostnote beállításaid",
|
||||||
"Help": "Súgó",
|
"Help": "Súgó",
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
".md": ".md",
|
".md": ".md",
|
||||||
".txt": ".txt",
|
".txt": ".txt",
|
||||||
".html": ".html",
|
".html": ".html",
|
||||||
|
".pdf": ".pdf",
|
||||||
"Print": "Stampa",
|
"Print": "Stampa",
|
||||||
"Your preferences for Boostnote": "Le tue preferenze per Boostnote",
|
"Your preferences for Boostnote": "Le tue preferenze per Boostnote",
|
||||||
"Storage Locations": "Posizioni",
|
"Storage Locations": "Posizioni",
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
".md": ".md",
|
".md": ".md",
|
||||||
".txt": ".txt",
|
".txt": ".txt",
|
||||||
".html": ".html",
|
".html": ".html",
|
||||||
|
".pdf": ".pdf",
|
||||||
"Print": "印刷",
|
"Print": "印刷",
|
||||||
"Your preferences for Boostnote": "Boostnoteの個人設定",
|
"Your preferences for Boostnote": "Boostnoteの個人設定",
|
||||||
"Help": "ヘルプ",
|
"Help": "ヘルプ",
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
".md": ".md",
|
".md": ".md",
|
||||||
".txt": ".txt",
|
".txt": ".txt",
|
||||||
".html": ".html",
|
".html": ".html",
|
||||||
|
".pdf": ".pdf",
|
||||||
"Print": "인쇄",
|
"Print": "인쇄",
|
||||||
"Your preferences for Boostnote": "Boostnote 설정",
|
"Your preferences for Boostnote": "Boostnote 설정",
|
||||||
"Storage Locations": "저장소",
|
"Storage Locations": "저장소",
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
".md": ".md",
|
".md": ".md",
|
||||||
".txt": ".txt",
|
".txt": ".txt",
|
||||||
".html": ".html",
|
".html": ".html",
|
||||||
|
".pdf": ".pdf",
|
||||||
"Print": "Print",
|
"Print": "Print",
|
||||||
"Your preferences for Boostnote": "Your preferences for Boostnote",
|
"Your preferences for Boostnote": "Your preferences for Boostnote",
|
||||||
"Storage Locations": "Storage Locations",
|
"Storage Locations": "Storage Locations",
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
".md": ".md",
|
".md": ".md",
|
||||||
".txt": ".txt",
|
".txt": ".txt",
|
||||||
".html": ".html",
|
".html": ".html",
|
||||||
|
".pdf": ".pdf",
|
||||||
"Print": "Drukuj",
|
"Print": "Drukuj",
|
||||||
"Help": "Pomoc",
|
"Help": "Pomoc",
|
||||||
"Your preferences for Boostnote": "Twoje ustawienia dla Boostnote",
|
"Your preferences for Boostnote": "Twoje ustawienia dla Boostnote",
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
".md": ".md",
|
".md": ".md",
|
||||||
".txt": ".txt",
|
".txt": ".txt",
|
||||||
".html": ".html",
|
".html": ".html",
|
||||||
|
".pdf": ".pdf",
|
||||||
"Print": "Imprimir",
|
"Print": "Imprimir",
|
||||||
"Your preferences for Boostnote": "Suas preferências para o Boostnote",
|
"Your preferences for Boostnote": "Suas preferências para o Boostnote",
|
||||||
"Storage Locations": "Armazenamentos",
|
"Storage Locations": "Armazenamentos",
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
".md": ".md",
|
".md": ".md",
|
||||||
".txt": ".txt",
|
".txt": ".txt",
|
||||||
".html": ".html",
|
".html": ".html",
|
||||||
|
".pdf": ".pdf",
|
||||||
"Print": "Imprimir",
|
"Print": "Imprimir",
|
||||||
"Your preferences for Boostnote": "As tuas definiçōes para Boostnote",
|
"Your preferences for Boostnote": "As tuas definiçōes para Boostnote",
|
||||||
"Storage Locations": "Locais de Armazenamento",
|
"Storage Locations": "Locais de Armazenamento",
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
".md": ".md",
|
".md": ".md",
|
||||||
".txt": ".txt",
|
".txt": ".txt",
|
||||||
".html": ".html",
|
".html": ".html",
|
||||||
|
".pdf": ".pdf",
|
||||||
"Print": "Print",
|
"Print": "Print",
|
||||||
"Your preferences for Boostnote": "Настройки Boostnote",
|
"Your preferences for Boostnote": "Настройки Boostnote",
|
||||||
"Storage Locations": "Хранилища",
|
"Storage Locations": "Хранилища",
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
".md": ".md",
|
".md": ".md",
|
||||||
".txt": ".txt",
|
".txt": ".txt",
|
||||||
".html": ".html",
|
".html": ".html",
|
||||||
|
".pdf": ".pdf",
|
||||||
"Print": "Print",
|
"Print": "Print",
|
||||||
"Your preferences for Boostnote": "Your preferences for Boostnote",
|
"Your preferences for Boostnote": "Your preferences for Boostnote",
|
||||||
"Storage Locations": "Storage Locations",
|
"Storage Locations": "Storage Locations",
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
".md": ".md",
|
".md": ".md",
|
||||||
".txt": ".txt",
|
".txt": ".txt",
|
||||||
".html": ".html",
|
".html": ".html",
|
||||||
|
".pdf": ".pdf",
|
||||||
"Print": "พิมพ์",
|
"Print": "พิมพ์",
|
||||||
"Your preferences for Boostnote": "การตั้งค่าของคุณสำหรับ Boostnote",
|
"Your preferences for Boostnote": "การตั้งค่าของคุณสำหรับ Boostnote",
|
||||||
"Help": "ช่วยเหลือ",
|
"Help": "ช่วยเหลือ",
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
".md": ".md",
|
".md": ".md",
|
||||||
".txt": ".txt",
|
".txt": ".txt",
|
||||||
".html": ".html",
|
".html": ".html",
|
||||||
|
".pdf": ".pdf",
|
||||||
"Print": "Yazdır",
|
"Print": "Yazdır",
|
||||||
"Your preferences for Boostnote": "Boostnote tercihleriniz",
|
"Your preferences for Boostnote": "Boostnote tercihleriniz",
|
||||||
"Storage Locations": "Saklama Alanları",
|
"Storage Locations": "Saklama Alanları",
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
".md": ".md",
|
".md": ".md",
|
||||||
".txt": ".txt",
|
".txt": ".txt",
|
||||||
".html": ".html",
|
".html": ".html",
|
||||||
|
".pdf": ".pdf",
|
||||||
"Print": "打印",
|
"Print": "打印",
|
||||||
"Your preferences for Boostnote": "个性设置",
|
"Your preferences for Boostnote": "个性设置",
|
||||||
"Storage Locations": "本地存储",
|
"Storage Locations": "本地存储",
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
".md": ".md",
|
".md": ".md",
|
||||||
".txt": ".txt",
|
".txt": ".txt",
|
||||||
".html": ".html",
|
".html": ".html",
|
||||||
|
".pdf": ".pdf",
|
||||||
"Print": "列印",
|
"Print": "列印",
|
||||||
"Your preferences for Boostnote": "Boostnote 偏好設定",
|
"Your preferences for Boostnote": "Boostnote 偏好設定",
|
||||||
"Storage Locations": "儲存空間",
|
"Storage Locations": "儲存空間",
|
||||||
|
|||||||
Reference in New Issue
Block a user