summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/compilationManager.ts2
-rw-r--r--src/main/index.ts4
-rw-r--r--src/main/overleafSocket.ts31
3 files changed, 31 insertions, 6 deletions
diff --git a/src/main/compilationManager.ts b/src/main/compilationManager.ts
index 3529345..8fbd946 100644
--- a/src/main/compilationManager.ts
+++ b/src/main/compilationManager.ts
@@ -15,7 +15,7 @@ export class CompilationManager {
constructor(projectId: string, cookie: string) {
this.projectId = projectId
this.cookie = cookie
- this.tmpDir = join(require('os').tmpdir(), `claudetex-${projectId}`)
+ this.tmpDir = join(require('os').tmpdir(), `lattex-${projectId}`)
}
get dir(): string {
diff --git a/src/main/index.ts b/src/main/index.ts
index 89a04b0..7fc1c4d 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -211,9 +211,9 @@ ipcMain.handle('overleaf:webLogin', async () => {
// Inject a floating back button when navigated away from overleaf.com
const injectBackButton = () => {
loginWindow.webContents.executeJavaScript(`
- if (!document.getElementById('claudetex-back-btn')) {
+ if (!document.getElementById('lattex-back-btn')) {
const btn = document.createElement('div');
- btn.id = 'claudetex-back-btn';
+ btn.id = 'lattex-back-btn';
btn.innerHTML = '← Back';
btn.style.cssText = 'position:fixed;top:8px;left:8px;z-index:999999;padding:6px 14px;' +
'background:#333;color:#fff;border-radius:6px;cursor:pointer;font:13px -apple-system,sans-serif;' +
diff --git a/src/main/overleafSocket.ts b/src/main/overleafSocket.ts
index 52ac20f..1a12260 100644
--- a/src/main/overleafSocket.ts
+++ b/src/main/overleafSocket.ts
@@ -9,6 +9,15 @@ import {
encodeHeartbeat
} from './overleafProtocol'
+/** Decode WebSocket-encoded UTF-8 text (reverses server's unescape(encodeURIComponent(text))) */
+function decodeUtf8(text: string): string {
+ try {
+ return decodeURIComponent(escape(text))
+ } catch {
+ return text // already decoded or pure ASCII
+ }
+}
+
export interface JoinProjectResult {
publicId: string
project: {
@@ -252,14 +261,30 @@ export class OverleafSocket extends EventEmitter {
this.joinedDocs.add(docId)
// Ack response format: [error, docLines, version, updates, ranges, pathname]
- // First element is error (null = success)
const err = result[0]
if (err) throw new Error(`joinDoc failed: ${JSON.stringify(err)}`)
- const docLines = (result[1] as string[]) || []
+ // Server encodes lines + range text via unescape(encodeURIComponent(text))
+ // for safe WebSocket transport. Decode with decodeURIComponent(escape(text)).
+ const rawLines = (result[1] as string[]) || []
+ const docLines = rawLines.map(line => decodeUtf8(line))
const version = (result[2] as number) || 0
const updates = (result[3] as unknown[]) || []
- const ranges = (result[4] || { comments: [], changes: [] }) as JoinDocResult['ranges']
+ const rawRanges = result[4] as JoinDocResult['ranges'] | undefined
+
+ // Decode range text (op.c, op.i, op.d) — positions (op.p) stay as-is
+ const ranges = rawRanges || { comments: [], changes: [] }
+ if (ranges.comments) {
+ for (const c of ranges.comments) {
+ if (c.op?.c) c.op.c = decodeUtf8(c.op.c)
+ }
+ }
+ if (ranges.changes) {
+ for (const ch of ranges.changes as any[]) {
+ if (ch.op?.i) ch.op.i = decodeUtf8(ch.op.i)
+ if (ch.op?.d) ch.op.d = decodeUtf8(ch.op.d)
+ }
+ }
return { docLines, version, updates, ranges }
}