@lobehub/editor 4.23.2 → 4.24.0

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/es/headless.js CHANGED
@@ -8157,7 +8157,7 @@ const MathPlugin = class extends KernelPlugin {
8157
8157
  }
8158
8158
  registerMarkdown() {
8159
8159
  const markdownService = this.kernel.requireService(IMarkdownShortCutService);
8160
- markdownService?.registerMarkdownShortCut({
8160
+ if (this.config?.enableInlineMath !== false) markdownService?.registerMarkdownShortCut({
8161
8161
  regExp: /\$([^\s$](?:[^$]*[^\s$])?)\$\s?$/,
8162
8162
  replace: (textNode, match) => {
8163
8163
  const [, code] = match;
@@ -8192,7 +8192,7 @@ const MathPlugin = class extends KernelPlugin {
8192
8192
  ctx.appendLine(node.getTextContent());
8193
8193
  return true;
8194
8194
  });
8195
- markdownService?.registerMarkdownReader("inlineMath", (node) => {
8195
+ if (this.config?.enableInlineMath !== false) markdownService?.registerMarkdownReader("inlineMath", (node) => {
8196
8196
  return INodeHelper.createElementNode("math", {
8197
8197
  code: node.value,
8198
8198
  version: 1
@@ -5,6 +5,8 @@ import { LexicalEditor } from "lexical";
5
5
  //#region src/plugins/math/plugin/index.d.ts
6
6
  interface MathPluginOptions {
7
7
  decorator?: (node: MathInlineNode | MathBlockNode, editor: LexicalEditor) => unknown;
8
+ /** Enable `$...$` shortcuts and Markdown inline-math parsing. Defaults to true. */
9
+ enableInlineMath?: boolean;
8
10
  theme?: {
9
11
  mathBlock?: string;
10
12
  mathInline?: string;
@@ -66,7 +66,7 @@ const MathPlugin = class extends KernelPlugin {
66
66
  }
67
67
  registerMarkdown() {
68
68
  const markdownService = this.kernel.requireService(IMarkdownShortCutService);
69
- markdownService?.registerMarkdownShortCut({
69
+ if (this.config?.enableInlineMath !== false) markdownService?.registerMarkdownShortCut({
70
70
  regExp: /\$([^\s$](?:[^$]*[^\s$])?)\$\s?$/,
71
71
  replace: (textNode, match) => {
72
72
  const [, code] = match;
@@ -101,7 +101,7 @@ const MathPlugin = class extends KernelPlugin {
101
101
  ctx.appendLine(node.getTextContent());
102
102
  return true;
103
103
  });
104
- markdownService?.registerMarkdownReader("inlineMath", (node) => {
104
+ if (this.config?.enableInlineMath !== false) markdownService?.registerMarkdownReader("inlineMath", (node) => {
105
105
  return INodeHelper.createElementNode("math", {
106
106
  code: node.value,
107
107
  version: 1
@@ -8,11 +8,12 @@ import MathInline from "./components/MathInline.js";
8
8
  import { useLayoutEffect } from "react";
9
9
  import { jsx } from "react/jsx-runtime";
10
10
  //#region src/plugins/math/react/index.tsx
11
- const ReactMathPlugin = ({ className, renderComp, theme }) => {
11
+ const ReactMathPlugin = ({ className, enableInlineMath, renderComp, theme }) => {
12
12
  const [editor] = useLexicalComposerContext();
13
13
  useLayoutEffect(() => {
14
14
  editor.registerPlugin(MarkdownPlugin);
15
15
  editor.registerPlugin(MathPlugin, {
16
+ enableInlineMath,
16
17
  decorator: (node, editor) => {
17
18
  return /* @__PURE__ */ jsx(MathInline, {
18
19
  className,
@@ -25,8 +26,8 @@ const ReactMathPlugin = ({ className, renderComp, theme }) => {
25
26
  }, [
26
27
  editor,
27
28
  className,
28
- theme,
29
- styles
29
+ enableInlineMath,
30
+ theme
30
31
  ]);
31
32
  return /* @__PURE__ */ jsx(MathEdit, { renderComp });
32
33
  };
@@ -2,6 +2,8 @@ import { FC, ReactNode } from "react";
2
2
  //#region src/plugins/math/react/type.d.ts
3
3
  interface ReactMathPluginProps {
4
4
  className?: string;
5
+ /** Enable `$...$` shortcuts and Markdown inline-math parsing. Defaults to true. */
6
+ enableInlineMath?: boolean;
5
7
  /** 自定义渲染组件,接收 MathEditorContent 作为子节点 */
6
8
  renderComp?: FC<{
7
9
  children: ReactNode;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/editor",
3
- "version": "4.23.2",
3
+ "version": "4.24.0",
4
4
  "description": "A powerful and extensible rich text editor built on Meta's Lexical framework, providing a modern editing experience with React integration.",
5
5
  "keywords": [
6
6
  "lobehub",