File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33
44import Prism from 'prismjs'
55import hljs from 'highlight.js'
6- // Fix PDFObject import to work with both dev and prod builds
7- import * as PDFObjectModule from 'pdfobject'
6+ import * as PDFObject from 'pdfobject'
87
98import { saveAs } from 'file-saver'
109
@@ -67,8 +66,6 @@ import { instance as vizInstance } from '@viz-js/viz'
6766let viz = null
6867vizInstance ( ) . then ( instance => { viz = instance } )
6968
70- const PDFObject = PDFObjectModule . default || PDFObjectModule
71-
7269const ui = getUIElements ( )
7370
7471// auto update last change
Original file line number Diff line number Diff line change 1+ if ( typeof window . ot === 'undefined' ) {
2+ window . ot = { } ;
3+ }
Original file line number Diff line number Diff line change @@ -95,11 +95,12 @@ import '@vendor/inlineAttachment/codemirror.inline-attachment'
9595import Visibility from 'visibilityjs'
9696// Import the original vendor file
9797
98+ import './global-ot'
9899import '@hackmd/ot'
99100import '@hackmd/ot/lib/socketio-adapter'
100101import '@hackmd/ot/lib/codemirror-adapter'
101102import '@hackmd/ot/lib/undo-manager'
102- // import '@hackmd/ot/lib/client'
103+ import '@hackmd/ot/lib/client'
103104import '@hackmd/ot/lib/editor-client'
104105
105106import * as mousewheel from 'jquery-mousewheel'
@@ -226,8 +227,7 @@ import '@css/extra.css'
226227import '@css/site.css'
227228import 'spin.js/spin.css'
228229
229- const mw = mousewheel . default || mousewheel // Fix for mousewheel import
230- mw ( $ )
230+ mousewheel ?. default ?. ( $ )
231231
232232// ot.Client = Client
233233// ot.EditorClient = EditorClient
Original file line number Diff line number Diff line change @@ -125,6 +125,14 @@ export default defineConfig({
125125 emptyOutDir : true , // Clean the output directory before building
126126 manifest : true , // Generate manifest.json
127127 rollupOptions : {
128+ moduleContext : ( id ) => {
129+ const modules = [ 'pdfobject' , 'jquery-mousewheel' ]
130+
131+ if ( modules . some ( module => id . includes ( module ) ) ) {
132+ return 'window' // Set context for specific modules
133+ }
134+ return undefined
135+ } ,
128136 input : {
129137 // Define JS entry points
130138 index : path . resolve ( __dirname , 'public/js/index.js' ) ,
@@ -140,7 +148,7 @@ export default defineConfig({
140148 // Example: 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
141149 __dirname : '""' , // Define __dirname as empty string for browser compatibility
142150 global : 'globalThis' , // Explicitly define global for Vite
143- ot : { } // Define ot as empty object for browser compatibility
151+ // ot: {} // Define ot as empty object for browser compatibility
144152 } ,
145153 root : __dirname ,
146154 base : '/.vite/' , // Updated to match our custom base path in app.js
You can’t perform that action at this time.
0 commit comments