diff --git a/examples/advanced/grading-papers-comments-annotations/package.json b/examples/advanced/grading-papers-comments-annotations/package.json index e11d3c67b..f3c9b0150 100644 --- a/examples/advanced/grading-papers-comments-annotations/package.json +++ b/examples/advanced/grading-papers-comments-annotations/package.json @@ -11,7 +11,8 @@ "dependencies": { "pdfjs-dist": "4.3.136", "react": "^19.0.0", - "react-dom": "^19.0.0" + "react-dom": "^19.0.0", + "superdoc": "../../../packages/superdoc" }, "devDependencies": { "@vitejs/plugin-react": "^4.0.4", diff --git a/examples/advanced/grading-papers-comments-annotations/src/App.jsx b/examples/advanced/grading-papers-comments-annotations/src/App.jsx index 9542114e0..72a4693a2 100644 --- a/examples/advanced/grading-papers-comments-annotations/src/App.jsx +++ b/examples/advanced/grading-papers-comments-annotations/src/App.jsx @@ -1,13 +1,15 @@ -import '@harbour-enterprises/superdoc/style.css'; +import 'superdoc/style.css'; import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import Header from './components/Header.jsx'; import AssignmentHeader from './components/AssignmentHeader.jsx'; import Drawer from './components/Drawer.jsx'; -import { SuperDoc } from '@harbour-enterprises/superdoc'; +import { SuperDoc } from 'superdoc'; import NickPDF from '/nick.pdf?url'; import * as pdfjsLib from 'pdfjs-dist/build/pdf.mjs'; import * as pdfjsViewer from 'pdfjs-dist/web/pdf_viewer.mjs'; +pdfjsLib.GlobalWorkerOptions.workerSrc = new URL('pdfjs-dist/build/pdf.worker.min.mjs', import.meta.url,).toString(); + const defaultWhiteboardOpacity = 1; const disabledWhiteboardOpacity = 0.5; @@ -16,7 +18,7 @@ const App = () => { const docFileRef = useRef(null); // UI state only (do not store SuperDoc instance in state). - const [whiteboardReady, setWhiteboardReady] = useState(false); + const [whiteboardInitialized, setWhiteboardInit] = useState(false); const [whiteboardEnabled, setWhiteboardEnabled] = useState(true); const [activeTool, setActiveTool] = useState('select'); @@ -51,15 +53,15 @@ const App = () => { const superdoc = superdocRef.current; if (!superdoc) return; superdoc.on('whiteboard:change', (data) => { - console.log('whiteboard:change', { data }); + console.log('whiteboard:change', data); }); superdoc.on('whiteboard:tool', (tool) => { setActiveTool(tool); }); }, []); - const onWhiteboardReady = useCallback((whiteboard) => { - setWhiteboardReady(true); + const onWhiteboardInit = useCallback((whiteboard) => { + setWhiteboardInit(true); setActiveTool(whiteboard?.getTool?.() ?? 'select'); registerStickers(); registerComments(); @@ -94,7 +96,8 @@ const App = () => { pdf: { pdfLib: pdfjsLib, pdfViewer: pdfjsViewer, - setWorker: true, + setWorker: false, + // workerSrc: '', textLayerMode: 0, }, whiteboard: { @@ -113,10 +116,10 @@ const App = () => { superdocRef.current = superdocInstance; window.superdoc = superdocInstance; - superdocInstance.on('whiteboard:ready', ({ whiteboard }) => { - onWhiteboardReady(whiteboard); + superdocInstance.on('whiteboard:init', ({ whiteboard }) => { + onWhiteboardInit(whiteboard); }); - }, [onWhiteboardReady]); + }, [onWhiteboardInit]); // Load selected file and boot SuperDoc. const handleNewFile = useCallback(async (fileName) => { @@ -163,7 +166,7 @@ const App = () => { const exportWhiteboard = useCallback(() => { const data = superdocRef.current?.whiteboard?.getWhiteboardData(); if (!data) return; - console.log('[Whiteboard] export', { data }); + console.log('[Whiteboard] export', data); console.log('[Whiteboard] export json:', JSON.stringify(data, null, 2)); }, []); @@ -202,7 +205,7 @@ const App = () => {