mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-29 00:20:04 +01:00
32 lines
939 B
JavaScript
32 lines
939 B
JavaScript
import { Node, mergeAttributes } from "@tiptap/core";
|
|
import { inputRules } from "prosemirror-inputrules";
|
|
import { makeBlockMathInputRule, REGEX_BLOCK_MATH_DOLLARS, } from "./plugin";
|
|
export var MathBlock = Node.create({
|
|
name: "math_display",
|
|
group: "block math",
|
|
content: "text*",
|
|
atom: true,
|
|
code: true,
|
|
parseHTML: function () {
|
|
return [
|
|
{
|
|
tag: "div[class*='math-display']", // important!
|
|
},
|
|
];
|
|
},
|
|
renderHTML: function (_a) {
|
|
var HTMLAttributes = _a.HTMLAttributes;
|
|
return [
|
|
"div",
|
|
mergeAttributes({ class: "math-display math-node" }, HTMLAttributes),
|
|
0,
|
|
];
|
|
},
|
|
addProseMirrorPlugins: function () {
|
|
var inputRulePlugin = inputRules({
|
|
rules: [makeBlockMathInputRule(REGEX_BLOCK_MATH_DOLLARS, this.type)],
|
|
});
|
|
return [inputRulePlugin];
|
|
},
|
|
});
|