mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-29 00:20:04 +01:00
34 lines
1022 B
JavaScript
34 lines
1022 B
JavaScript
import { Node, mergeAttributes } from "@tiptap/core";
|
|
import { inputRules } from "prosemirror-inputrules";
|
|
import { makeInlineMathInputRule, REGEX_INLINE_MATH_DOLLARS, mathPlugin, } from "./plugin";
|
|
import "katex/dist/katex.min.css";
|
|
export var MathInline = Node.create({
|
|
name: "math_inline",
|
|
group: "inline math",
|
|
content: "text*",
|
|
inline: true,
|
|
atom: true,
|
|
code: true,
|
|
parseHTML: function () {
|
|
return [
|
|
{
|
|
tag: "span[class*='math-inline']", // important!,
|
|
},
|
|
];
|
|
},
|
|
renderHTML: function (_a) {
|
|
var HTMLAttributes = _a.HTMLAttributes;
|
|
return [
|
|
"span",
|
|
mergeAttributes({ class: "math-inline math-node" }, HTMLAttributes),
|
|
0,
|
|
];
|
|
},
|
|
addProseMirrorPlugins: function () {
|
|
var inputRulePlugin = inputRules({
|
|
rules: [makeInlineMathInputRule(REGEX_INLINE_MATH_DOLLARS, this.type)],
|
|
});
|
|
return [mathPlugin, inputRulePlugin];
|
|
},
|
|
});
|