Skip to content

Commit 28c1d5f

Browse files
committed
fix(internal): remove pdfjs from build
1 parent 88ff88d commit 28c1d5f

File tree

15 files changed

+359
-248
lines changed

15 files changed

+359
-248
lines changed

package-lock.json

Lines changed: 22 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/superdoc/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
},
6565
"peerDependencies": {
6666
"@hocuspocus/provider": "^2.13.6",
67-
"pdfjs-dist": "4.3.136",
67+
"pdfjs-dist": ">=4.3.136 <=4.6.82",
6868
"y-prosemirror": "^1.2.12",
6969
"yjs": "13.6.19"
7070
},
@@ -77,6 +77,7 @@
7777
"pdfjs-dist": "4.3.136",
7878
"postcss-nested": "^6.0.1",
7979
"postcss-nested-import": "^1.3.0",
80+
"postcss-prefixwrap": "^1.56.2",
8081
"typescript": "^5.7.3",
8182
"vite": "^6.3.5",
8283
"vitest": "^3.2.4",
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1+
// packages/superdoc/src/components/PdfViewer/PdfViewer.vue
2+
const PDF_VIEWER_CLASS = '.superdoc-pdf-viewer';
3+
14
module.exports = {
25
plugins: [
36
require('postcss-nested'),
4-
require('postcss-nested-import'),
7+
// https://github.com/dbtedman/postcss-prefixwrap
8+
// This is necessary for pdf.js style scoping.
9+
require('postcss-prefixwrap')(PDF_VIEWER_CLASS, {
10+
whitelist: ['pdf-viewer.css'],
11+
ignoredSelectors: [],
12+
prefixRootTags: false,
13+
}),
514
]
615
}

packages/superdoc/src/SuperDoc.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ import {
1313
computed,
1414
reactive,
1515
watch,
16+
defineAsyncComponent,
1617
} from 'vue';
1718
import { NMessageProvider } from 'naive-ui';
1819
import { storeToRefs } from 'pinia';
1920
20-
import PdfViewer from './components/PdfViewer/PdfViewer.vue';
2121
import CommentsLayer from './components/CommentsLayer/CommentsLayer.vue';
2222
import CommentDialog from '@superdoc/components/CommentsLayer/CommentDialog.vue';
2323
import FloatingComments from '@superdoc/components/CommentsLayer/FloatingComments.vue';
@@ -35,6 +35,9 @@ import AiLayer from './components/AiLayer/AiLayer.vue';
3535
import { useSelectedText } from './composables/use-selected-text';
3636
import { useAi } from './composables/use-ai';
3737
import { useHighContrastMode } from './composables/use-high-contrast-mode';
38+
39+
const PdfViewer = defineAsyncComponent(() => import('./components/PdfViewer/PdfViewer.vue'));
40+
3841
// Stores
3942
const superdocStore = useSuperdocStore();
4043
const commentsStore = useCommentsStore();
@@ -104,6 +107,8 @@ const {
104107
// Hrbr Fields
105108
const hrbrFieldsLayer = ref(null);
106109
110+
const pdfConfig = proxy.$superdoc.config.modules?.pdf || {};
111+
107112
const handleDocumentReady = (documentId, container) => {
108113
const doc = getDocument(documentId);
109114
doc.isReady = true;
@@ -622,6 +627,7 @@ watch(getFloatingComments, () => {
622627
<PdfViewer
623628
v-if="doc.type === PDF"
624629
:document-data="doc"
630+
:config="pdfConfig"
625631
@selection-change="handleSelectionChange"
626632
@ready="handleDocumentReady"
627633
@page-loaded="handlePageReady"

0 commit comments

Comments
 (0)