MathBox

by JiangYan
5
4
3
2
1
Score: 50/100

Description

Create math functions more conveniently in obsidian.

Reviews

No reviews yet.

Stats

0
stars
35
downloads
0
forks
12
days
12
days
12
days
1
total PRs
0
open PRs
1
closed PRs
0
merged PRs
0
total issues
0
open issues
0
closed issues
47
commits

Latest Version

13 days ago

Changelog

MathBox 3.4.2

提交:878ddf1 — feat(v3.4.2): 社区审查整改——插件 ID 统一为 math-box、声明式设置、CSS 规范、工件认证

本次变更

feat(v3.4.2): 社区审查整改——插件 ID 统一为 math-box、声明式设置、CSS 规范、工件认证

## 插件 ID 变更(升级必读)

- 插件 id 由 `obsidian-math-box` 统一改为 `math-box`,与社区商店注册 ID 一致。
- **升级方法**:把 vault 内 `.obsidian/plugins/obsidian-math-box/` 文件夹**重命名**为
  `math-box`(设置与收藏随文件夹保留),重开 Obsidian 后在第三方插件中重新启用。

## 审查整改

- 设置页实现声明式 `getSettingDefinitions()`:Obsidian 1.13+ 可在**设置搜索**中检索本插件的全部设置;旧版本宿主行为不变。
- 移除默认热键 Ctrl/Cmd+M(避免与用户已有键位冲突),改为在「设置 → 快捷键」中自行绑定。
- 字体内联改用宿主 `requestUrl` 读取资源,不再使用全局 `fetch`。
- 移除已弃用的 `document.execCommand('copy')` 回退,剪贴板只走 `navigator.clipboard`。
- DOM 构建全部走宿主 `createEl` / `instanceOf`(跨窗口安全)。
- styles.css:清零全部 `!important`(改为选择器特异性);移除仅部分支持的
  `display: contents` 与 `scrollbar-width`;`mjx-container` 改用属性选择器;
  最小化几何改由 JS 源头配合(折叠期间不写内联高度),不再用 CSS 反压内联样式。

## 发布

- Release 资产(main.js / styles.css)附带 GitHub 构建工件认证(build provenance),
  可用 `gh attestation verify <文件> -R JiangYanCoder/MathBox` 验证资产确由本仓库源码构建。

安装

  1. 下载下方 main.js、manifest.json、styles.css 三个文件
  2. 在 vault 的 <vault>/.obsidian/plugins/math-box/ 创建同名文件夹(旧版用户请把原 obsidian-math-box 文件夹重命名为 math-box,设置与收藏随文件夹保留) (文件夹名必须与 manifest.json 的 id 完全一致)
  3. 把三个文件放入该文件夹
  4. 重启 Obsidian,或在「第三方插件」中重新开启 MathBox

README file from

Github

MathBox

v3.4.2 — A visual LaTeX formula editor for Obsidian: live preview on top, LaTeX source below, an option bar in between, and a collapsible side pane holding symbols, templates and favorites.

一个显式的上下分栏公式编辑器:上方实时渲染、下方编辑 LaTeX 源码,中间选项栏控制字号 / 字体 / 颜色并提供行内、行间两种插入方式;右侧可展开侧边栏承载常用符号、公式模板与收藏夹。

侧边栏三页(快捷工具 / 公式模板 / 收藏夹)中的公式与符号均由宿主 MathJax 渲染,字体与笔记 正文里的公式完全一致(Computer Modern / TeX)。

图像导出(SVG / PNG)走 MathJax 原生 SVG 输出:字形是内嵌的矢量路径,不依赖任何字体文件, 导出的图在任何查看器里都与预览逐像素一致,且可无限缩放。

Features / 功能

Three entry points ribbon icon, editor right-click menu (Insert formula with MathBox), command MathBox: Open MathBox formula editor (no default hotkey — bind your own in Settings → Hotkeys)
Live preview rendered through the host MathJax (renderMath), 200 ms debounce, errors reported without blanking the last good render
Option bar font size / font family / color / environment on the left; Insert inline · Insert display on the right
Display font size the preview and the source pane each have their own − value + stepper, left of Favorite / Copy: 1 px steps, or click the number and type a value (Enter or blur applies, Esc cancels, clearing it resets); preview 12–30 px, source 11–30 px, persisted across restarts
Source pane monospace editor with copy / clear; pasting strips $, $$, \(\), \[\] delimiters automatically
Symbol palette 13 groups / 370 items, every button rendered as a real formula (Computer Modern / TeX); lazy-rendered with a per-formula cache so the pane opens instantly
Formula templates 9 groups / 66 items, each entry previewed as a rendered formula instead of raw LaTeX
Favorites search / pin / rename / regroup / delete; stored in the plugin's data.json, JSON import & export
Hover hints two-line tooltip: line 1 the LaTeX source, line 2 a Chinese / English description (all 370 symbols covered)
Matrix entries buttons preview a 2×2 case (a₁₁ … a₂₂) and insert a 2×2 skeleton with & / \\ already in place; arbitrary sizes via the custom matrix dialog
Export LaTeX, MathML, SVG (native vector — glyphs as paths, no font dependency), PNG at 3×; white or transparent background, switchable right in the export menu
i18n 简体中文 / English, auto follows the app language
Theme every color comes from Obsidian CSS variables; icons are Lucide via setIcon

Usage / 使用

  1. Open the panel from any of the three entry points.
  2. Type LaTeX below (or click symbols/templates in the side pane).
  3. Watch the preview; use the − / + stepper above to scale the preview (and the one above the source pane to scale the code), or apply font size / font / color to the formula itself.
  4. Click Inline formula or Display formula — the panel closes and the formula is written into the note in a single editor operation, so one Ctrl+Z undoes it.

If a selection that looks like LaTeX (starts with \, or is wrapped in $…$) is present when the panel is opened from the menu or the hotkey, it is pre-filled into the source pane.

Side-pane symbol order: Common → Greek → Relations → Arrows → Sets & Logic → Fractions → Radicals → Limits → Trigonometry → Integrals → Large operators → Brackets → Arrays & matrices.

Settings / 设置

  • Interface language — follow app language / 简体中文 / English
  • Default font size — preview (12–30 px) and source (11–30 px). The −/+ steppers inside the panel write back to these two values; a ↺ button in front of each field restores that row only to the software default (preview 18 px, source 13 px — the measured v3.4.0 baseline)
  • Expand non-standard macros on insert — rewrites physics-style commands (\vb{}, \abs{}, \dv{}{}, …) as standard LaTeX so the formula stays portable outside Obsidian
  • Use compact display math — $$x$$ on one line vs. a fenced block on its own lines
  • Export image background — white (best for pasting into documents) or transparent (blends into any page). The same switch also sits at the top of the export menu, so you needn't leave the panel. With a transparent background the glyphs take the current theme's foreground colour.
  • Favorites — export / import JSON, clear all

Version history

Version Highlights
3.4.2 Plugin id renamed to math-box — rename the plugin folder to math-box when upgrading (settings/favorites are preserved with the folder, then re-enable the plugin); settings searchable via declarative getSettingDefinitions() (Obsidian 1.13+); no default hotkey anymore (bind your own in Settings → Hotkeys); host requestUrl instead of fetch; removed deprecated execCommand fallback; CSS lint cleanup (zero !important, dropped partially-supported CSS); release assets now ship build-provenance attestations
3.4.1 Display font size for the preview and the source pane: − value + steppers left of Favorite / Copy, buttons sized like the neighbouring icon buttons, click the value to type (Enter/blur applies, Esc cancels without closing the panel, clearing resets), 1 px steps, preview 12–30 px / source 11–30 px, persisted; the two sizes are exposed as default sizes in settings with a per-row ↺ reset
3.4.0 Image export switched to native MathJax SVG output (glyphs as <path>, no font dependency, ~7 KB vs ~288 KB); white / transparent background switchable in the export menu; size gate raised to 2000 KB
3.3.0 Side pane fully rendered through host MathJax (symbols, templates, favorites); two-line hover hints; matrix previews + 2×2 insertion skeletons; group re-ordering; 370 bilingual remarks
3.2.x Favorites groups, adaptive option bar, panel/tab/popout entry points
3.0.0 Renamed to MathBox; three-column layout with collapsible side pane; multi-format export
2.0.0 Right-click invoked three-pane editor (render / source / templates)
1.0.0 Inline palette on inserting a formula block

This plugin follows the official Obsidian sample plugin structure (TypeScript + esbuild).