Skip to content

Commit

Permalink
fix: pdf and evernote failure without title
Browse files Browse the repository at this point in the history
fixes #48
  • Loading branch information
shuowu committed Jul 10, 2020
1 parent 37c6215 commit 3e089fa
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
6 changes: 4 additions & 2 deletions packages/common/services/integration/evernote/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ class Generator {
`<a style="padding-bottom: 20px;" href="${INSTALLATION_URL}">YiNote</a>`
)}</span>`;
nBody += '<br/>';
nBody += `<div>${description}</div>`;
if (description) {
nBody += `<div>${description}</div>`;
}
nBody += '<br/>';
const resources = [];
notes.forEach(note => {
Expand Down Expand Up @@ -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;

Expand Down
9 changes: 6 additions & 3 deletions packages/common/services/pdf/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ');
Expand Down
5 changes: 4 additions & 1 deletion packages/extension/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -292,5 +292,8 @@
},
"star_github": {
"message": "github.com/shuowu/yi-note"
},
"title_default": {
"message": "Notes sent from YiNote"
}
}
}

0 comments on commit 3e089fa

Please sign in to comment.