From 7c1cd50defdde200eeb8300fc7336ac47f77a6d0 Mon Sep 17 00:00:00 2001 From: Evan Miller Date: Mon, 3 Dec 2018 13:12:22 -0500 Subject: [PATCH] Add structure for exporting PDFs --- browser/components/MarkdownPreview.js | 9 +++++++++ browser/main/Detail/InfoPanel.js | 8 +++++++- browser/main/Detail/InfoPanelTrashed.js | 7 ++++--- browser/main/Detail/MarkdownNoteDetail.js | 6 ++++++ browser/main/NoteList/index.js | 1 + lib/main-menu.js | 7 +++++++ locales/da.json | 1 + locales/de.json | 1 + locales/en.json | 1 + locales/es-ES.json | 1 + locales/fa.json | 1 + locales/fr.json | 1 + locales/hu.json | 1 + locales/it.json | 1 + locales/ja.json | 1 + locales/ko.json | 1 + locales/no.json | 1 + locales/pl.json | 1 + locales/pt-BR.json | 1 + locales/pt-PT.json | 1 + locales/ru.json | 1 + locales/sq.json | 1 + locales/th.json | 1 + locales/tr.json | 1 + locales/zh-CN.json | 1 + locales/zh-TW.json | 1 + 26 files changed, 54 insertions(+), 4 deletions(-) diff --git a/browser/components/MarkdownPreview.js b/browser/components/MarkdownPreview.js index 17d2cb82..87d1d02a 100755 --- a/browser/components/MarkdownPreview.js +++ b/browser/components/MarkdownPreview.js @@ -205,6 +205,7 @@ export default class MarkdownPreview extends React.Component { this.saveAsTextHandler = () => this.handleSaveAsText() this.saveAsMdHandler = () => this.handleSaveAsMd() this.saveAsHtmlHandler = () => this.handleSaveAsHtml() + this.saveAsPdfHandler = () => this.handleSaveAsPdf() this.printHandler = () => this.handlePrint() 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 () { 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-md', this.saveAsMdHandler) eventEmitter.on('export:save-html', this.saveAsHtmlHandler) + eventEmitter.on('export:save-pdf', this.saveAsPdfHandler) 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-md', this.saveAsMdHandler) eventEmitter.off('export:save-html', this.saveAsHtmlHandler) + eventEmitter.off('export:save-pdf', this.saveAsPdfHandler) eventEmitter.off('print', this.printHandler) } diff --git a/browser/main/Detail/InfoPanel.js b/browser/main/Detail/InfoPanel.js index 15535186..8fe0a855 100644 --- a/browser/main/Detail/InfoPanel.js +++ b/browser/main/Detail/InfoPanel.js @@ -14,7 +14,7 @@ class InfoPanel extends React.Component { render () { 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 return (
@@ -85,6 +85,11 @@ class InfoPanel extends React.Component {

{i18n.__('.html')}

+ + - @@ -61,7 +61,8 @@ InfoPanelTrashed.propTypes = { createdAt: PropTypes.string.isRequired, exportAsMd: PropTypes.func.isRequired, exportAsTxt: PropTypes.func.isRequired, - exportAsHtml: PropTypes.func.isRequired + exportAsHtml: PropTypes.func.isRequired, + exportAsPdf: PropTypes.func.isRequired } export default CSSModules(InfoPanelTrashed, styles) diff --git a/browser/main/Detail/MarkdownNoteDetail.js b/browser/main/Detail/MarkdownNoteDetail.js index b4e7a5b3..08d8bfbd 100755 --- a/browser/main/Detail/MarkdownNoteDetail.js +++ b/browser/main/Detail/MarkdownNoteDetail.js @@ -190,6 +190,10 @@ class MarkdownNoteDetail extends React.Component { ee.emit('export:save-html') } + exportAsPdf () { + ee.emit('export:save-pdf') + } + handleKeyDown (e) { switch (e.keyCode) { // tab key @@ -411,6 +415,7 @@ class MarkdownNoteDetail extends React.Component { exportAsHtml={this.exportAsHtml} exportAsMd={this.exportAsMd} exportAsTxt={this.exportAsTxt} + exportAsPdf={this.exportAsPdf} />
@@ -476,6 +481,7 @@ class MarkdownNoteDetail extends React.Component { exportAsMd={this.exportAsMd} exportAsTxt={this.exportAsTxt} exportAsHtml={this.exportAsHtml} + exportAsPdf={this.exportAsPdf} wordCount={note.content.split(' ').length} letterCount={note.content.replace(/\r?\n/g, '').length} type={note.type} diff --git a/browser/main/NoteList/index.js b/browser/main/NoteList/index.js index 31efaede..b5748fd4 100644 --- a/browser/main/NoteList/index.js +++ b/browser/main/NoteList/index.js @@ -500,6 +500,7 @@ class NoteList extends React.Component { 'export-txt': 'Text export', 'export-md': 'Markdown export', 'export-html': 'HTML export', + 'export-pdf': 'PDF export', 'print': 'Print' })[msg] diff --git a/lib/main-menu.js b/lib/main-menu.js index eb08273a..012c9ea3 100644 --- a/lib/main-menu.js +++ b/lib/main-menu.js @@ -116,6 +116,13 @@ const file = { mainWindow.webContents.send('list:isMarkdownNote', 'export-html') mainWindow.webContents.send('export:save-html') } + }, + { + label: 'PDF (.pdf)', + click () { + mainWindow.webContents.send('list:isMarkdownNote', 'export-pdf') + mainWindow.webContents.send('export:save-pdf') + } } ] }, diff --git a/locales/da.json b/locales/da.json index da5843f3..5d1a392b 100644 --- a/locales/da.json +++ b/locales/da.json @@ -18,6 +18,7 @@ ".md": ".md", ".txt": ".txt", ".html": ".html", + ".pdf": ".pdf", "Print": "Print", "Your preferences for Boostnote": "Your preferences for Boostnote", "Storage Locations": "Storage Locations", diff --git a/locales/de.json b/locales/de.json index 1b90ab63..9177adec 100644 --- a/locales/de.json +++ b/locales/de.json @@ -18,6 +18,7 @@ ".md": ".md", ".txt": ".txt", ".html": ".html", + ".pdf": ".pdf", "Print": "Drucken", "Your preferences for Boostnote": "Boostnote Einstellungen", "Storage Locations": "Speicherverwaltung", diff --git a/locales/en.json b/locales/en.json index fe7931da..831789c1 100644 --- a/locales/en.json +++ b/locales/en.json @@ -19,6 +19,7 @@ ".md": ".md", ".txt": ".txt", ".html": ".html", + ".pdf": ".pdf", "Print": "Print", "Your preferences for Boostnote": "Your preferences for Boostnote", "Help": "Help", diff --git a/locales/es-ES.json b/locales/es-ES.json index 8b2da1b7..3bd2cb49 100644 --- a/locales/es-ES.json +++ b/locales/es-ES.json @@ -18,6 +18,7 @@ ".md": ".md", ".txt": ".txt", ".html": ".html", + ".pdf": ".pdf", "Print": "Imprimir", "Your preferences for Boostnote": "Tus preferencias para Boostnote", "Storage Locations": "Almacenamientos", diff --git a/locales/fa.json b/locales/fa.json index 18bef679..8f702767 100644 --- a/locales/fa.json +++ b/locales/fa.json @@ -18,6 +18,7 @@ ".md": ".md", ".txt": ".txt", ".html": ".html", + ".pdf": ".pdf", "Print": "پرینت", "Your preferences for Boostnote": "تنظیمات شما برای boostnote", "Storage Locations": "ذخیره سازی", diff --git a/locales/fr.json b/locales/fr.json index ea5a1c05..35d2f3c8 100644 --- a/locales/fr.json +++ b/locales/fr.json @@ -18,6 +18,7 @@ ".md": ".md", ".txt": ".txt", ".html": ".html", + ".pdf": ".pdf", "Print": "Imprimer", "Your preferences for Boostnote": "Vos préférences pour Boostnote", "Storage Locations": "Stockages", diff --git a/locales/hu.json b/locales/hu.json index 77bdb2ab..e76f06c9 100644 --- a/locales/hu.json +++ b/locales/hu.json @@ -19,6 +19,7 @@ ".md": ".md", ".txt": ".txt", ".html": ".html", + ".pdf": ".pdf", "Print": "Nyomtatás", "Your preferences for Boostnote": "Boostnote beállításaid", "Help": "Súgó", diff --git a/locales/it.json b/locales/it.json index 05f454f3..69ddd380 100644 --- a/locales/it.json +++ b/locales/it.json @@ -18,6 +18,7 @@ ".md": ".md", ".txt": ".txt", ".html": ".html", + ".pdf": ".pdf", "Print": "Stampa", "Your preferences for Boostnote": "Le tue preferenze per Boostnote", "Storage Locations": "Posizioni", diff --git a/locales/ja.json b/locales/ja.json index e33bbaa6..b9618381 100644 --- a/locales/ja.json +++ b/locales/ja.json @@ -19,6 +19,7 @@ ".md": ".md", ".txt": ".txt", ".html": ".html", + ".pdf": ".pdf", "Print": "印刷", "Your preferences for Boostnote": "Boostnoteの個人設定", "Help": "ヘルプ", diff --git a/locales/ko.json b/locales/ko.json index 9a8bf8c7..59ffe7b9 100644 --- a/locales/ko.json +++ b/locales/ko.json @@ -18,6 +18,7 @@ ".md": ".md", ".txt": ".txt", ".html": ".html", + ".pdf": ".pdf", "Print": "인쇄", "Your preferences for Boostnote": "Boostnote 설정", "Storage Locations": "저장소", diff --git a/locales/no.json b/locales/no.json index 2d6c92f5..66109a34 100644 --- a/locales/no.json +++ b/locales/no.json @@ -18,6 +18,7 @@ ".md": ".md", ".txt": ".txt", ".html": ".html", + ".pdf": ".pdf", "Print": "Print", "Your preferences for Boostnote": "Your preferences for Boostnote", "Storage Locations": "Storage Locations", diff --git a/locales/pl.json b/locales/pl.json index 68719aef..577f46e6 100644 --- a/locales/pl.json +++ b/locales/pl.json @@ -19,6 +19,7 @@ ".md": ".md", ".txt": ".txt", ".html": ".html", + ".pdf": ".pdf", "Print": "Drukuj", "Help": "Pomoc", "Your preferences for Boostnote": "Twoje ustawienia dla Boostnote", diff --git a/locales/pt-BR.json b/locales/pt-BR.json index 6b3126cc..6072b023 100644 --- a/locales/pt-BR.json +++ b/locales/pt-BR.json @@ -18,6 +18,7 @@ ".md": ".md", ".txt": ".txt", ".html": ".html", + ".pdf": ".pdf", "Print": "Imprimir", "Your preferences for Boostnote": "Suas preferências para o Boostnote", "Storage Locations": "Armazenamentos", diff --git a/locales/pt-PT.json b/locales/pt-PT.json index 774919a2..5beb18dd 100644 --- a/locales/pt-PT.json +++ b/locales/pt-PT.json @@ -18,6 +18,7 @@ ".md": ".md", ".txt": ".txt", ".html": ".html", + ".pdf": ".pdf", "Print": "Imprimir", "Your preferences for Boostnote": "As tuas definiçōes para Boostnote", "Storage Locations": "Locais de Armazenamento", diff --git a/locales/ru.json b/locales/ru.json index 793e1511..c4e9e1a2 100644 --- a/locales/ru.json +++ b/locales/ru.json @@ -18,6 +18,7 @@ ".md": ".md", ".txt": ".txt", ".html": ".html", + ".pdf": ".pdf", "Print": "Print", "Your preferences for Boostnote": "Настройки Boostnote", "Storage Locations": "Хранилища", diff --git a/locales/sq.json b/locales/sq.json index e4cc01ac..80f737a3 100644 --- a/locales/sq.json +++ b/locales/sq.json @@ -18,6 +18,7 @@ ".md": ".md", ".txt": ".txt", ".html": ".html", + ".pdf": ".pdf", "Print": "Print", "Your preferences for Boostnote": "Your preferences for Boostnote", "Storage Locations": "Storage Locations", diff --git a/locales/th.json b/locales/th.json index 49d8e7cd..358d49ab 100644 --- a/locales/th.json +++ b/locales/th.json @@ -19,6 +19,7 @@ ".md": ".md", ".txt": ".txt", ".html": ".html", + ".pdf": ".pdf", "Print": "พิมพ์", "Your preferences for Boostnote": "การตั้งค่าของคุณสำหรับ Boostnote", "Help": "ช่วยเหลือ", diff --git a/locales/tr.json b/locales/tr.json index 03a9791d..077fa1e4 100644 --- a/locales/tr.json +++ b/locales/tr.json @@ -18,6 +18,7 @@ ".md": ".md", ".txt": ".txt", ".html": ".html", + ".pdf": ".pdf", "Print": "Yazdır", "Your preferences for Boostnote": "Boostnote tercihleriniz", "Storage Locations": "Saklama Alanları", diff --git a/locales/zh-CN.json b/locales/zh-CN.json index 2e12323e..8e5537d2 100755 --- a/locales/zh-CN.json +++ b/locales/zh-CN.json @@ -18,6 +18,7 @@ ".md": ".md", ".txt": ".txt", ".html": ".html", + ".pdf": ".pdf", "Print": "打印", "Your preferences for Boostnote": "个性设置", "Storage Locations": "本地存储", diff --git a/locales/zh-TW.json b/locales/zh-TW.json index 93a8afd5..add73073 100755 --- a/locales/zh-TW.json +++ b/locales/zh-TW.json @@ -18,6 +18,7 @@ ".md": ".md", ".txt": ".txt", ".html": ".html", + ".pdf": ".pdf", "Print": "列印", "Your preferences for Boostnote": "Boostnote 偏好設定", "Storage Locations": "儲存空間",