Skip to content

Commit ef1edef

Browse files
committed
update
1 parent 71806c3 commit ef1edef

13 files changed

Lines changed: 160 additions & 8 deletions

File tree

src/components/BootstrapBlazor.CherryMarkdown/Components/CherryMarkdown/CherryMarkdown.razor.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ public partial class CherryMarkdown
2525
[Parameter]
2626
public ToolbarSettings? ToolbarSettings { get; set; }
2727

28+
/// <summary>
29+
/// 获得/ 设置 是否使用 Katex 渲染数学公式
30+
/// </summary>
31+
[Parameter]
32+
public bool UseKatex { get; set; }
33+
2834
private string? _lastValue;
2935
/// <summary>
3036
/// 获得/设置 组件值
@@ -71,6 +77,7 @@ protected override void OnInitialized()
7177

7278
_lastValue = Value;
7379
Option.Value = Value;
80+
Option.UseKatex = UseKatex;
7481
Option.Editor = EditorSettings ?? new EditorSettings();
7582
Option.Toolbars = ToolbarSettings ?? new ToolbarSettings();
7683
if (IsViewer == true)

src/components/BootstrapBlazor.CherryMarkdown/Components/CherryMarkdown/CherryMarkdown.razor.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1-
import '../../js/cherry-markdown.min.js'
2-
import { addLink } from '../../../BootstrapBlazor/modules/utility.js'
1+
import '../../js/cherry-markdown.core.js'
2+
import { addLink, addScript } from '../../../BootstrapBlazor/modules/utility.js'
33
import Data from '../../../BootstrapBlazor/modules/data.js'
44

55
export async function init(id, invoker, options, callback) {
66
await addLink('./_content/BootstrapBlazor.CherryMarkdown/css/cherry-markdown.min.css')
77

8+
if (options.useKatex){
9+
await addScript('./_content/BootstrapBlazor.CherryMarkdown/js/katex.min.js')
10+
await addLink('./_content/BootstrapBlazor.CherryMarkdown/css/katex.min.css')
11+
options.engine = {syntax : { mathBlock: {engine: 'katex', },
12+
inlineMath: {engine: 'katex'}}}
13+
options.externals = {katex: window.katex}
14+
}
15+
delete options.useKatexuseKatex
816
const el = document.getElementById(id);
917
if (el === null) {
1018
return;
@@ -43,9 +51,7 @@ export async function init(id, invoker, options, callback) {
4351

4452
md._editor = new Cherry({
4553
el: md._element,
46-
value: md._options.value,
47-
editor: md._options.editor,
48-
toolbars: md._options.toolbars,
54+
... md._options,
4955
callback: {
5056
afterChange: (markdown, html) => {
5157
md._invoker.invokeMethodAsync('Update', [markdown, html])

src/components/BootstrapBlazor.CherryMarkdown/Components/CherryMarkdown/CherryMarkdownOption.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,9 @@ internal class CherryMarkdownOption
2323
/// 工具栏选项
2424
/// </summary>
2525
public ToolbarSettings? Toolbars { get; set; }
26+
27+
/// <summary>
28+
/// 是否使用 Katex 渲染数学公式
29+
/// </summary>
30+
public bool UseKatex { get; set; }
2631
}

src/components/BootstrapBlazor.CherryMarkdown/wwwroot/css/cherry-markdown.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.

src/components/BootstrapBlazor.CherryMarkdown/wwwroot/css/fonts/ch-icon.svg

Lines changed: 133 additions & 1 deletion
Loading
Binary file not shown.
Binary file not shown.
Binary file not shown.

src/components/BootstrapBlazor.CherryMarkdown/wwwroot/css/katex.min.css

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

0 commit comments

Comments
 (0)