Skip to content

Commit

Permalink
feat(pdf): image entity insert
Browse files Browse the repository at this point in the history
  • Loading branch information
Novout committed Oct 7, 2021
1 parent c412703 commit d981604
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion FEATURES.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Here will contain all the features that Better Write offers.
- ✅ - Paragraph Italic
- ✅ - Paragraph Links
- ✅ - Heading's
- - Image's
- - Image's
- ❌ - Emoji's
- ✅ - Break Page
- ✅ - Line Page
Expand Down
20 changes: 20 additions & 0 deletions src/use/pdf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,24 @@ export const usePDF: Callback<any> = () => {
}
}

const image = (raw: string, store: Store<any>) => {
return {
image: raw,
width:
useDefines().pdf().base().pageSizeFixes()[
store.state.pdf.styles.base.pageSize
][0] -
generate().base(store).pageMargins[0] -
generate().base(store).pageMargins[2],
margin: [
generate().base(store).pageMargins[0],
10,
generate().base(store).pageMargins[2],
10,
],
}
}

const frontCover = (store: Store<any>, arr: Array<any>) => {
if (store.state.pdf.styles.switcher.cover) {
if (!store.state.pdf.styles.base.background.data) return
Expand Down Expand Up @@ -222,6 +240,8 @@ export const usePDF: Callback<any> = () => {
_raw = pageBreak()
} else if ((entity as any).type === 'line-break') {
_raw = lineBreak()
} else if ((entity as any).type === 'image') {
_raw = image((entity as any).raw, store)
}

arr.push(_raw)
Expand Down

0 comments on commit d981604

Please sign in to comment.