From 3e089fa609f4210696077c0fb628aed9a91aa877 Mon Sep 17 00:00:00 2001 From: Shuo Wu Date: Fri, 10 Jul 2020 18:48:08 -0400 Subject: [PATCH] fix: pdf and evernote failure without title fixes #48 --- .../common/services/integration/evernote/generator.js | 6 ++++-- packages/common/services/pdf/index.js | 9 ++++++--- packages/extension/_locales/en/messages.json | 5 ++++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/common/services/integration/evernote/generator.js b/packages/common/services/integration/evernote/generator.js index b8d220b..d7920ae 100644 --- a/packages/common/services/integration/evernote/generator.js +++ b/packages/common/services/integration/evernote/generator.js @@ -31,7 +31,9 @@ class Generator { `YiNote` )}`; nBody += '
'; - nBody += `
${description}
`; + if (description) { + nBody += `
${description}
`; + } nBody += '
'; const resources = []; notes.forEach(note => { @@ -66,7 +68,7 @@ class Generator { // Create note object const note = new EvernoteSDK.Types.Note(); note.notebookGuid = notebook.guid; - note.title = title; + note.title = title || browser.i18n.getMessage('title_default'); note.content = nBody; note.resources = resources; diff --git a/packages/common/services/pdf/index.js b/packages/common/services/pdf/index.js index a86f0e9..bb2e50b 100644 --- a/packages/common/services/pdf/index.js +++ b/packages/common/services/pdf/index.js @@ -42,9 +42,12 @@ export default class PDFGenerator { this.doc.setFont('msyh'); this.doc.setFontType('normal'); let y = 20; - this.doc.setFontSize(18); - this.doc.text(20, y, this.doc.splitTextToSize(title, 180)); - y += Math.ceil(title.length / 50) * 18; + + if (title) { + this.doc.setFontSize(18); + this.doc.text(20, y, this.doc.splitTextToSize(title, 180)); + y += Math.ceil(title.length / 50) * 18; + } this.doc.setFontSize(12); this.doc.text(20, y, 'Generated from '); diff --git a/packages/extension/_locales/en/messages.json b/packages/extension/_locales/en/messages.json index 38d3b83..ade9217 100644 --- a/packages/extension/_locales/en/messages.json +++ b/packages/extension/_locales/en/messages.json @@ -292,5 +292,8 @@ }, "star_github": { "message": "github.com/shuowu/yi-note" + }, + "title_default": { + "message": "Notes sent from YiNote" } -} \ No newline at end of file +}