Skip to content

Commit

Permalink
Export rotation styles for annotation and text layers
Browse files Browse the repository at this point in the history
  • Loading branch information
hrynko committed Jan 21, 2024
1 parent e981bc2 commit 089359e
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,23 @@ export default defineConfig({
copy({
hook: 'writeBundle',
targets: Object.entries({
textLayer: [0, 116],
annotationLayer: [118, 486],
}).map(([key, [start, end]]) => ({
textLayer: [
[0, 116],
[1835, 1845],
],
annotationLayer: [
[118, 486],
[1835, 1845],
],
}).map(([key, ranges]) => ({
src: 'node_modules/pdfjs-dist/web/pdf_viewer.css',
dest: 'dist/style',
rename: `${key}.css`,
transform: (contents) => {
const css = contents
.toString()
.split('\n')
.slice(start, end)
.join('\n')
const lines = contents.toString().split('\n')
const css = ranges.reduce((acc, [start, end]) => {
return acc + lines.slice(start, end).join('\n')
}, '')
return new CleanCSS().minify(css).styles + '\n'
},
})),
Expand Down

0 comments on commit 089359e

Please sign in to comment.