# wangEditor-plugin-formula **Repository Path**: weilingmu_tangscsh/wangEditor-plugin-formula ## Basic Information - **Project Name**: wangEditor-plugin-formula - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2025-09-16 - **Last Updated**: 2025-09-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # wangEditor 公式 [English Documentation](./README-en.md) ## 介绍 [wangEditor](https://www.wangeditor.com/) 公式插件,使用 [LateX](https://baike.baidu.com/item/LaTeX/1212106) 语法。 ![](./_img/demo.png) ## 安装 ```shell yarn add katex yarn add @wangeditor/plugin-formula ``` ## 使用 ### 注册到编辑器 ```js import { Boot, IEditorConfig, IToolbarConfig } from '@wangeditor/editor' import formulaModule from '@wangeditor/plugin-formula' // 注册。要在创建编辑器之前注册,且只能注册一次,不可重复注册。 Boot.registerModule(formulaModule) ``` ### 配置 ```js // 编辑器配置 const editorConfig: Partial = { // 选中公式时的悬浮菜单 hoverbarKeys: { formula: { menuKeys: ['editFormula'], // “编辑公式”菜单 }, }, // 其他... } // 工具栏配置 const toolbarConfig: Partial = { insertKeys: { index: 0, keys: [ 'insertFormula', // “插入公式”菜单 // 'editFormula' // “编辑公式”菜单 ], }, // 其他... } ``` 然后创建编辑器和工具栏,会用到 `editorConfig` 和 `toolbarConfig` 。具体查看 wangEditor 文档。 ### 显示 HTML 公式获取的 HTML 格式如下 ```html ``` 其中 `data-value` 就是 LateX 格式的值,可使用第三方工具把 `` 渲染成公式卡片,如 [KateX](https://katex.org/)。 ## 其他 支持 i18n 多语言