Skip to content

Commit 890c823

Browse files
committed
fix(plugin): supports empty options in runner
1 parent a496779 commit 890c823

4 files changed

Lines changed: 7 additions & 30 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ It's simple!
3434
### NPM
3535

3636
```shell
37-
npm install pdfeasy
37+
npm i pdfeasy
3838
```
3939

4040
### YARN

packages/pdfeasy-docs/.vitepress/theme/components/Demo.vue

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121
2222
__RENDERING__.value = true
2323
24-
pdfeasy.new({
25-
plugins: [],
26-
})
24+
pdfeasy.new()
2725
2826
await pdfeasy.add(parse)
2927
@@ -34,7 +32,6 @@
3432
},
3533
})
3634
.then((blob) => {
37-
console.log('here?')
3835
iframe.value.src = blob
3936
})
4037
.catch((res) => {

packages/pdfeasy-vite-demo/src/main.ts

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,6 @@ pdfeasy.new({
1616
right: 80
1717
}
1818
},
19-
plugins: [
20-
{
21-
page: [ // render callback in every page before finish contents insert.
22-
// simple counter footer
23-
({ Text, Image }, context, current, total) => {
24-
// render in every page
25-
Text(`${current}/${total}`, { fontSize: 20 }, {
26-
x: context.width / 2,
27-
y: context.height - context.margins.bottom
28-
})
29-
30-
// Image('https://i.imgur.com/J3JXhsl.png', {}, {})
31-
},
32-
// simple header
33-
({ Text }, context, current, total) => {
34-
// render in every page
35-
Text('A Simple Header', {}, {
36-
x: context.width / 2,
37-
// negative number (-30 in case) ignore default margins
38-
y: context.margins.top - 20
39-
})
40-
}
41-
]
42-
}
43-
]
4419
})
4520

4621
pdfeasy.add([

packages/pdfeasy/src/plugins/page.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ export const pageHandler = (instance: pdfeasy): Promise<void> => {
148148
return
149149
}
150150

151+
if (!instance.options?.plugins) {
152+
response()
153+
return
154+
}
155+
151156
const range = doc.bufferedPageRange()
152157

153158
let actually: number, total: number

0 commit comments

Comments
 (0)