dsh-latex-formula-editor 1.0.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +150 -38
- package/README.md +147 -41
- package/client.js +210 -210
- package/cordis.patch.yml +22 -0
- package/docs/img/doc-ocr.png +0 -0
- package/docs/img/editor.png +0 -0
- package/docs/img/favourites.png +0 -0
- package/docs/img/help.png +0 -0
- package/docs/img/hover.png +0 -0
- package/docs/img/settings.png +0 -0
- package/docs/img/templates.png +0 -0
- package/icon.svg +6 -6
- package/index.js +683 -652
- package/lib/00-core.js +1313 -1313
- package/lib/10-latex.js +2091 -2091
- package/lib/20-render.js +1553 -1553
- package/lib/30-visual.js +1053 -1053
- package/lib/35-tiles.js +1705 -1705
- package/lib/50-app.js +1765 -1765
- package/lib/56-recognition-panels.js +2292 -2281
- package/lib/60-settings-help.js +757 -757
- package/lib/90-skin.js +761 -761
- package/package.json +49 -46
- package/README.zh.md +0 -41
- package/docs/img/palette.png +0 -0
- package/docs/img/v15-fav.png +0 -0
package/README.en.md
CHANGED
|
@@ -1,38 +1,150 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-

|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/dsh-latex-formula-editor)
|
|
6
|
+
[](https://github.com/topics/dsh-plugin)
|
|
7
|
+
|
|
8
|
+
A free, open-source and fully offline LaTeX formula editor that lives in the **left sidebar** of the DeepSeek Harness Web UI (icon `Σ`).
|
|
9
|
+
Interaction follows [latexlive.com](https://www.latexlive.com/), but everything runs on your own machine: maths is rendered by the
|
|
10
|
+
bundled MathJax, PDFs are parsed by the bundled PDF.js — no account, no quota, no uploads (except the recognition backend you configure).
|
|
11
|
+
|
|
12
|
+
- Sidebar entry → one panel with five views: **Editor / Image OCR / Document OCR / Favourites / Help**
|
|
13
|
+
- Live LaTeX rendering (MathJax 3.2.2, SVG output, offline)
|
|
14
|
+
- UI scale **125%** by default (Settings → UI scale, 100%–200%)
|
|
15
|
+
- Light / dark theme switch (follows the system by default), 简体中文 / 繁體中文 / English
|
|
16
|
+
- Share links encode the formula in the URL hash — nothing goes through a server
|
|
17
|
+
- Nine export formats plus four export menus (image / code / escape / share)
|
|
18
|
+
|
|
19
|
+

|
|
20
|
+
|
|
21
|
+
## Features
|
|
22
|
+
|
|
23
|
+
### Quick tools
|
|
24
|
+
|
|
25
|
+
Ten tiles above the input: **common symbols / Greek / fractions & calculus / roots & scripts / limits & logs / trigonometry /
|
|
26
|
+
integrals / large operators / brackets & floors / matrices**.
|
|
27
|
+
|
|
28
|
+
- Each tile icon is a live-typeset representative formula, not an image
|
|
29
|
+
- Hovering a tile expands its symbol panel **4px below**, grouped exactly like the palette data (e.g. Greek → lower case 30 / upper case 11); it collapses when the pointer leaves
|
|
30
|
+
- Every symbol has a ☆ in its corner to save it to favourites; clicking the symbol inserts it at the caret
|
|
31
|
+
- The tile strip scrolls horizontally with the mouse wheel (vertical wheel is translated), so the right-most tiles are reachable
|
|
32
|
+
|
|
33
|
+

|
|
34
|
+
|
|
35
|
+
### Templates
|
|
36
|
+
|
|
37
|
+
Ten template tiles: **algebra / geometry / inequalities / integrals / matrices / trigonometry / statistics / sequences /
|
|
38
|
+
physics / chemistry** — hover to expand and insert a ready-made snippet (quadratic roots, law of cosines, AM-GM,
|
|
39
|
+
binomial theorem, variance, geometric series, Schrödinger equation, chemical equations …).
|
|
40
|
+
|
|
41
|
+

|
|
42
|
+
|
|
43
|
+
### Format row
|
|
44
|
+
|
|
45
|
+
A separate row below the tiles, divided by a rule, with eight equal 62px icon buttons:
|
|
46
|
+
|
|
47
|
+
| Button | What it does |
|
|
48
|
+
| --- | --- |
|
|
49
|
+
| Colour | Palette icon + colour picker; picking a colour wraps the selection in `\textcolor{#hex}{…}` |
|
|
50
|
+
| Font | Roman / bold / italic / underline / sans / blackboard / calligraphic / fraktur, each rendered in that font inside the menu |
|
|
51
|
+
| Size | Nine steps from tiny to huge, each rendered at that size inside the menu |
|
|
52
|
+
| Environment | align / aligned / gathered / cases / split / array / eqnarray, plus "none" (strips the outer environment); wraps the selection in `\begin{…}…\end{…}` |
|
|
53
|
+
| Clear | Empties the source |
|
|
54
|
+
| Undo | Undo the previous edit (keystrokes within 400 ms merge, up to 120 steps) |
|
|
55
|
+
| Import | Reads `.tex` / `.txt` |
|
|
56
|
+
| Favourite | Saves the current formula to favourites |
|
|
57
|
+
|
|
58
|
+
With a selection the text is wrapped; without one an empty shell is inserted and the caret placed inside.
|
|
59
|
+
|
|
60
|
+
### Favourites
|
|
61
|
+
|
|
62
|
+
The fifth tab; every favourite is a card:
|
|
63
|
+
|
|
64
|
+
- **Title** ("Untitled formula" by default, click to rename), **timestamp**, **rendered preview**, **LaTeX source** (click to copy)
|
|
65
|
+
- **Insert / Copy / Delete** buttons
|
|
66
|
+
- A search box filters by **title or source**
|
|
67
|
+
- The cap defaults to **10** (Settings → Favourites limit, 1–50); the oldest entry is dropped beyond it
|
|
68
|
+
|
|
69
|
+

|
|
70
|
+
|
|
71
|
+
### Output
|
|
72
|
+
|
|
73
|
+
The export bar sits at the top of the preview column, with four menus:
|
|
74
|
+
|
|
75
|
+
| Menu | Options |
|
|
76
|
+
| --- | --- |
|
|
77
|
+
| Image | SVG / PNG / JPG (3× scale) |
|
|
78
|
+
| Code | LaTeX, AsciiMath, Typst, SVG Code, HTML inline, HTML display, MathML, MathML (mml:), MathML (m:), MathML (attr:), OMML |
|
|
79
|
+
| Escape | Escaped backslash, `$…$`, `$$…$$`, `\(…\)`, `\[…\]`, JSON string |
|
|
80
|
+
| Share | Copy the share link (`#tex=` encoded — opening it restores the formula) |
|
|
81
|
+
|
|
82
|
+
AsciiMath and Typst are produced by a real TeX parser and OMML by converting the MathML DOM into Word's formula structure — not by copying the LaTeX source.
|
|
83
|
+
|
|
84
|
+
The canvas background follows the theme: white in the light theme, black in the dark theme (transparent / white / dark can still be picked manually).
|
|
85
|
+
|
|
86
|
+
### Recognition
|
|
87
|
+
|
|
88
|
+
- **Image OCR**: drop, paste or pick an image; the configured model returns LaTeX and inserts it
|
|
89
|
+
- **Document OCR**: renders each PDF page and recognises it page by page; when done you can **download Word / LaTeX / Markdown**, and results from the last 15 days can be downloaded again without using quota
|
|
90
|
+
|
|
91
|
+

|
|
92
|
+
|
|
93
|
+
### Interface
|
|
94
|
+
|
|
95
|
+
- **125%** scale by default, adjustable 100%–200%; narrow panels switch to a compact layout (tabs wrap, actions become icons, panels scroll internally)
|
|
96
|
+
- Light / dark slider (sun / moon icons), system default
|
|
97
|
+
- Language menu: 简体中文 / 繁體中文 / English (traditional Chinese is derived from the simplified dictionary on the fly)
|
|
98
|
+
|
|
99
|
+

|
|
100
|
+
|
|
101
|
+
## Install
|
|
102
|
+
|
|
103
|
+
The plugin is normally mounted from a **local directory** (`link:` dependency), and it is also available on npm:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
# local directory
|
|
107
|
+
git clone https://github.com/jiahui-huang1/dsh-latex-formula-editor.git
|
|
108
|
+
pnpm dsh plugin add ./dsh-latex-formula-editor
|
|
109
|
+
|
|
110
|
+
# or from npm
|
|
111
|
+
pnpm dsh plugin add dsh-latex-formula-editor
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Then enable **LaTeX Formula Editor** in the DSH sidebar (entry id `latex-editor`). Restart DSH after changing the plugin.
|
|
115
|
+
|
|
116
|
+
## Layout
|
|
117
|
+
|
|
118
|
+
```
|
|
119
|
+
index.js Host half: static asset routes, recognition endpoint, settings persistence, latex_formula tool
|
|
120
|
+
client.js Client entry: registers the sidebar entry (sidebar.panellist) and the main panel (main)
|
|
121
|
+
lib/
|
|
122
|
+
├─ 00-core.js namespace, i18n, settings store, UI primitives, icons
|
|
123
|
+
├─ 10-latex.js symbol palette / templates / parser / source utilities
|
|
124
|
+
├─ 20-render.js MathJax rendering, nine export formats, PDF writer
|
|
125
|
+
├─ 30-visual.js legacy symbol / template panels and structure tree
|
|
126
|
+
├─ 35-tiles.js quick-tool and template tiles, favourites, export menus
|
|
127
|
+
├─ 40-recognition.js recognition backends (harness model / OpenAI-compatible endpoint)
|
|
128
|
+
├─ 45-convert.js TeX → AsciiMath / Typst, MathML → OMML
|
|
129
|
+
├─ 50-app.js main UI: editor, preview, export, history, share
|
|
130
|
+
├─ 56-recognition-panels.js image and document OCR panels
|
|
131
|
+
├─ 60-settings-help.js settings and help page
|
|
132
|
+
└─ 90-skin.js corporate-clean skin and theme tokens
|
|
133
|
+
vendor/ MathJax 3.2.2 and PDF.js (shipped with the plugin)
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Settings
|
|
137
|
+
|
|
138
|
+
- **Editor**: UI scale (125% default), source font size, word wrap, formula numbering, favourites limit
|
|
139
|
+
- **Recognition**: `auto` prefers the harness model; otherwise fill in an OpenAI-compatible endpoint (URL / model / key)
|
|
140
|
+
- Rendering and export are fully offline; only OCR sends the image to your backend
|
|
141
|
+
- Settings live in `<DSH_HOME>/latex-editor/settings.json`
|
|
142
|
+
|
|
143
|
+
## Requirements
|
|
144
|
+
|
|
145
|
+
- DSH ≥ 1.0 (Cordis plugin spec: `dsh.bundle.patch` + `dsh.client`)
|
|
146
|
+
- No build step on the browser side; MathJax and PDF.js ship with the plugin
|
|
147
|
+
|
|
148
|
+
## Licence
|
|
149
|
+
|
|
150
|
+
MIT
|
package/README.md
CHANGED
|
@@ -1,41 +1,147 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-

|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/dsh-latex-formula-editor)
|
|
6
|
+
[](https://github.com/topics/dsh-plugin)
|
|
7
|
+
|
|
8
|
+
一个免费开源、可离线使用的 LaTeX 公式编辑器,挂在 DeepSeek Harness Web UI 的**左侧栏**(图标 `Σ`)。
|
|
9
|
+
交互参考 [latexlive.com](https://www.latexlive.com/),但**全部在自己的机器上运行**:数学渲染用随包分发的
|
|
10
|
+
MathJax,PDF 解析用随包分发的 PDF.js,没有账号、没有额度、也不会上传(除了你自己配置的识别后端)。
|
|
11
|
+
|
|
12
|
+
- 侧栏入口 → 主面板,五个视图:**编辑器 / 图片识别 / 文档识别 / 收藏夹 / 帮助**
|
|
13
|
+
- LaTeX 实时渲染(MathJax 3.2.2,SVG 输出,离线)
|
|
14
|
+
- 界面缩放默认 **125%**(设置 → 界面缩放可在 100%–200% 之间切换)
|
|
15
|
+
- 浅色 / 深色主题一键切换(默认跟随系统),简体中文 / 繁體中文 / English 三语
|
|
16
|
+
- 分享链接把公式编码进 URL hash,不经过任何服务器
|
|
17
|
+
- 九种导出格式 + 四组导出菜单(图片 / 代码 / 转义 / 分享)
|
|
18
|
+
|
|
19
|
+

|
|
20
|
+
|
|
21
|
+
## 功能
|
|
22
|
+
|
|
23
|
+
### 快捷工具
|
|
24
|
+
|
|
25
|
+
输入区上方是 10 张磁贴:**常用符号 / 希腊字母 / 分数微分 / 根式角标 / 极限对数 / 三角函数 / 积分运算 / 大型运算 / 括号取整 / 数组矩阵**。
|
|
26
|
+
|
|
27
|
+
- 磁贴图标是按分类实时排版的代表公式,不是图片
|
|
28
|
+
- 悬停磁贴在正下方 **4px** 处展开该分类的符号面板,并按数据里的分组分节(如希腊字母 → 小写字母 30 / 大写字母 11),移开自动收拢
|
|
29
|
+
- 面板里每个符号右上角有 ☆,点一下收藏到收藏夹,点击符号本身插入到光标处
|
|
30
|
+
- 磁贴行支持**滚轮横向滚动**(竖向滚轮自动转成横向),最右侧磁贴可滚到
|
|
31
|
+
|
|
32
|
+

|
|
33
|
+
|
|
34
|
+
### 公式模板
|
|
35
|
+
|
|
36
|
+
10 张模板磁贴:**代数 / 几何 / 不等式 / 积分 / 矩阵 / 三角 / 统计 / 数列 / 物理 / 化学**,悬停展开后整条插入现成模板(求根公式、余弦定理、均值不等式、二项式定理、方差、等比数列求和、薛定谔方程、化学方程式等)。
|
|
37
|
+
|
|
38
|
+

|
|
39
|
+
|
|
40
|
+
### 格式工具
|
|
41
|
+
|
|
42
|
+
磁贴行下方用分隔线隔开的独立一行,8 个等宽图标按钮(62px):
|
|
43
|
+
|
|
44
|
+
| 按钮 | 说明 |
|
|
45
|
+
| --- | --- |
|
|
46
|
+
| 颜色 | 调色盘图标 + 取色器,选色即把选中文字包进 `\textcolor{#hex}{…}` |
|
|
47
|
+
| 字体 | 正体 / 加粗 / 斜体 / 下划线 / 无衬线 / 黑板粗体 / 手写体 / 德文尖角体,下拉里每项用该字体真实渲染 |
|
|
48
|
+
| 字号 | 极小 → 巨无霸九档,下拉里每项用该字号真实渲染 |
|
|
49
|
+
| 环境 | align / aligned / gathered / cases / split / array / eqnarray,以及「无环境」(拆掉最外层环境);选中即包 `\begin{…}…\end{…}` |
|
|
50
|
+
| 清空 | 清空源码区 |
|
|
51
|
+
| 撤销 | 撤销上一步(连续输入 400ms 合并为一步,最多 120 步) |
|
|
52
|
+
| 导入 | 读取 `.tex` / `.txt` |
|
|
53
|
+
| 收藏 | 把当前公式存进收藏夹 |
|
|
54
|
+
|
|
55
|
+
有选中文字就包裹选中内容,没有则插入空壳并把光标放进去。
|
|
56
|
+
|
|
57
|
+
### 收藏夹
|
|
58
|
+
|
|
59
|
+
顶部第五个页签,每条收藏是一张卡片:
|
|
60
|
+
|
|
61
|
+
- **标题**(默认「未命名公式」,点击即可改名)、**收藏时间**、**渲染结果**、**LaTeX 源码**(点击即复制)
|
|
62
|
+
- **插入 / 复制 / 删除** 三个按钮
|
|
63
|
+
- 顶部搜索框可按**标题或源码**检索
|
|
64
|
+
- 数量上限默认 **10**,在 设置 → 收藏夹上限 调整(1–50),超出时丢弃最旧的一条
|
|
65
|
+
|
|
66
|
+

|
|
67
|
+
|
|
68
|
+
### 输出区域
|
|
69
|
+
|
|
70
|
+
导出条在预览区顶部,四组菜单:
|
|
71
|
+
|
|
72
|
+
| 菜单 | 选项 |
|
|
73
|
+
| --- | --- |
|
|
74
|
+
| 输出图片 | SVG / PNG / JPG(3× 倍率) |
|
|
75
|
+
| 输出代码 | LaTeX、AsciiMath、Typst、SVG Code、HTML 行内、HTML 独立、MathML、MathML(mml:)、MathML(m:)、MathML(attr:)、OMML |
|
|
76
|
+
| 转义 | 反斜杠转义、`$…$`、`$$…$$`、`\(…\)`、`\[…\]`、JSON 字符串 |
|
|
77
|
+
| 分享 | 复制分享链接(`#tex=` 编码,打开即回填公式) |
|
|
78
|
+
|
|
79
|
+
AsciiMath / Typst 由内置 TeX 解析器真实转换,OMML 由 MathML DOM 转换为 Word 公式结构,不是直接复制 LaTeX。
|
|
80
|
+
|
|
81
|
+
预览画布底色随主题自动切换:浅色主题白底、深色主题黑底(透明 / 白底 / 深色仍可手动覆盖)。
|
|
82
|
+
|
|
83
|
+
### 识别
|
|
84
|
+
|
|
85
|
+
- **图片识别**:拖拽、粘贴或选择图片,调用你配置的模型识别为 LaTeX 并插入编辑器
|
|
86
|
+
- **文档识别**:PDF 逐页渲染后识别,可挑页;完成后可**下载 Word / LaTeX / Markdown**,最近 15 天的识别记录可重新下载(不消耗额度)
|
|
87
|
+
|
|
88
|
+

|
|
89
|
+
|
|
90
|
+
### 界面
|
|
91
|
+
|
|
92
|
+
- 默认 **125%** 缩放,100%–200% 可调;窄面板自动进入紧凑布局(页签换行、图标化动作、面板内滚动)
|
|
93
|
+
- 浅色 / 深色主题滑块(太阳 / 月亮图标),默认跟随系统
|
|
94
|
+
- 语言菜单:简体中文 / 繁體中文 / English,繁体由简体词表实时转换
|
|
95
|
+
|
|
96
|
+

|
|
97
|
+
|
|
98
|
+
## 安装
|
|
99
|
+
|
|
100
|
+
本插件通过**本地目录**挂载到 DSH profile(`link:` 依赖),也可以从 npm 安装:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
# 方式一:本地目录
|
|
104
|
+
git clone https://github.com/jiahui-huang1/dsh-latex-formula-editor.git
|
|
105
|
+
pnpm dsh plugin add ./dsh-latex-formula-editor
|
|
106
|
+
|
|
107
|
+
# 方式二:npm 包
|
|
108
|
+
pnpm dsh plugin add dsh-latex-formula-editor
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
安装后在 DSH 左侧栏启用 **公式编辑器**(入口 id `latex-editor`)。修改插件后重启 DSH 即可生效。
|
|
112
|
+
|
|
113
|
+
## 目录结构
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
index.js Host 半:静态资源路由、识别接口、设置持久化、latex_formula 工具
|
|
117
|
+
client.js 客户端入口:注册侧栏入口(sidebar.panellist)与主面板(main)
|
|
118
|
+
lib/
|
|
119
|
+
├─ 00-core.js 命名空间、i18n、设置存储、UI 原子组件、图标
|
|
120
|
+
├─ 10-latex.js 符号表 / 模板 / 解析器 / 源码工具(纯逻辑)
|
|
121
|
+
├─ 20-render.js MathJax 渲染、九种导出格式、PDF 生成
|
|
122
|
+
├─ 30-visual.js 旧版符号面板 / 模板面板 / 结构树(新面板见 35-tiles)
|
|
123
|
+
├─ 35-tiles.js 快捷工具与公式模板磁贴、收藏夹、导出菜单
|
|
124
|
+
├─ 40-recognition.js 识别后端(Harness 模型 / OpenAI 兼容端点)
|
|
125
|
+
├─ 45-convert.js TeX → AsciiMath / Typst、MathML → OMML
|
|
126
|
+
├─ 50-app.js 主界面:编辑器、预览、导出、历史、分享
|
|
127
|
+
├─ 56-recognition-panels.js 图片识别与文档识别界面
|
|
128
|
+
├─ 60-settings-help.js 设置面板与帮助页
|
|
129
|
+
└─ 90-skin.js 企业简洁风皮肤与主题变量
|
|
130
|
+
vendor/ MathJax 3.2.2 与 PDF.js(随包分发)
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## 设置
|
|
134
|
+
|
|
135
|
+
- **编辑器**:界面缩放(默认 125%)、源码字号、自动换行、公式编号、收藏夹上限
|
|
136
|
+
- **识别**:`auto` 优先用 Harness 模型;也可填 OpenAI 兼容端点(URL / 模型 / Key)
|
|
137
|
+
- 渲染与导出完全离线,只有识别会把图片发给你配置的后端
|
|
138
|
+
- 设置保存在本机 `<DSH_HOME>/latex-editor/settings.json`
|
|
139
|
+
|
|
140
|
+
## 兼容性
|
|
141
|
+
|
|
142
|
+
- DSH ≥ 1.0(Cordis 插件规范:`dsh.bundle.patch` + `dsh.client`)
|
|
143
|
+
- 浏览器侧没有构建步骤,MathJax 与 PDF.js 已随插件内置
|
|
144
|
+
|
|
145
|
+
## 许可
|
|
146
|
+
|
|
147
|
+
MIT
|