Skip to content

Commit d13974c

Browse files
committed
fix: LaTeX format in exported markdown
* fix: LaTeX format in exported markdown * fix: copy issue
1 parent 2adbf83 commit d13974c

File tree

5 files changed

+36
-19
lines changed

5 files changed

+36
-19
lines changed

forge.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ module.exports = {
3939
productName: 'BingGPT',
4040
description: 'AI-powered copilot',
4141
productDescription: 'AI-powered copilot',
42-
version: '0.3.3',
42+
version: '0.3.4',
4343
categories: ['Utility'],
4444
maintainer: 'dice2o',
4545
homepage: 'https://github.com/dice2o/BingGPT',
@@ -56,7 +56,7 @@ module.exports = {
5656
productName: 'BingGPT',
5757
description: 'AI-powered copilot',
5858
productDescription: 'AI-powered copilot',
59-
version: '0.3.3',
59+
version: '0.3.4',
6060
categories: ['Utility'],
6161
maintainer: 'dice2o',
6262
homepage: 'https://github.com/dice2o/BingGPT',

main.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -197,14 +197,9 @@ const createWindow = () => {
197197
label: 'Reset',
198198
visible: parameters.selectionText.trim().length === 0,
199199
click: () => {
200-
const session = mainWindow.webContents.session
201-
session
202-
.clearStorageData({
203-
storages: ['localstorage', 'cookies'],
204-
})
205-
.then(() => {
206-
mainWindow.reload()
207-
})
200+
mainWindow.webContents.session.clearStorageData().then(() => {
201+
mainWindow.reload()
202+
})
208203
},
209204
},
210205
{
@@ -219,7 +214,7 @@ const createWindow = () => {
219214
},
220215
},
221216
{
222-
label: 'BingGPT v0.3.3',
217+
label: 'BingGPT v0.3.4',
223218
visible: parameters.selectionText.trim().length === 0,
224219
click: () => {
225220
shell.openExternal('https://github.com/dice2o/BingGPT/releases')
@@ -232,7 +227,7 @@ const createWindow = () => {
232227
isDarkMode ? 'dark' : 'light'
233228
}schemeovr=1&FORM=SHORUN&udscs=1&udsnav=1&setlang=${locale}&features=udssydinternal&clientscopes=windowheader,coauthor,chat,&udsframed=1`
234229
const userAgent =
235-
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36 Edg/112.0.0.0'
230+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.0.0'
236231
mainWindow.loadURL(bingUrl)
237232
// Open links in default browser
238233
mainWindow.webContents.setWindowOpenHandler(({ url }) => {

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "binggpt",
33
"productName": "BingGPT",
4-
"version": "0.3.3",
4+
"version": "0.3.4",
55
"description": "AI-powered copilot",
66
"author": "dice2o",
77
"license": "Apache-2.0",

preload.js

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,15 @@ window.addEventListener('DOMContentLoaded', () => {
8282
const composeWrapper = document.getElementsByClassName(
8383
'uds_coauthor_wrapper'
8484
)[0]
85-
const composeMain = document.getElementsByClassName('main')[0]
85+
const composeMain = document.getElementsByClassName('sidebar')[0]
8686
const insertBtn = document.getElementById('insert_button')
8787
const previewText = document.getElementById('preview_text')
8888
const previewOptions = document.getElementsByClassName('preview-options')[0]
8989
if (composeWrapper) {
9090
composeWrapper.style.cssText = 'margin-top: -64px'
9191
}
9292
if (composeMain) {
93-
composeMain.style.cssText =
94-
'height: calc(100% - 64px); margin-top: 64px; padding: 20px 10px'
93+
composeMain.style.cssText = 'height: calc(100% - 64px); margin-top: 64px'
9594
}
9695
if (insertBtn) {
9796
insertBtn.style.cssText = 'display: none'
@@ -338,9 +337,32 @@ const markdownHandler = (element) => {
338337
return `> **${content}**`
339338
},
340339
})
340+
turndownService.addRule('latex', {
341+
filter: (node) => {
342+
return node.classList.contains('katex-block')
343+
},
344+
replacement: (content, node) => {
345+
return `$$${node.querySelector('annotation').innerHTML}$$`
346+
},
347+
})
348+
turndownService.addRule('inlineLatex', {
349+
filter: (node) => {
350+
return node.classList.contains('katex')
351+
},
352+
replacement: (content, node) => {
353+
return `$${node.querySelector('annotation').innerHTML}$`
354+
},
355+
})
341356
const mdDataURL = Buffer.from(
342-
turndownService.turndown(element),
357+
turndownService.turndown(element) + '\n',
343358
'utf-8'
344359
).toString('base64')
345360
ipcRenderer.send('export-data', 'md', mdDataURL)
346361
}
362+
363+
// Fix copy issue
364+
window.addEventListener('copy', (event) => {
365+
const selection = document.getSelection()
366+
event.clipboardData.setData('text/plain', selection.toString())
367+
event.preventDefault()
368+
})

0 commit comments

Comments
 (0)