mirror of
https://github.com/docmost/docmost.git
synced 2025-11-12 11:32:37 +10:00
change math node attribute name
This commit is contained in:
@ -15,7 +15,7 @@ export interface MathBlockOptions {
|
||||
}
|
||||
|
||||
export interface MathBlockAttributes {
|
||||
katex: string;
|
||||
text: string;
|
||||
}
|
||||
|
||||
export const inputRegex = /(?:^|\s)((?:\$\$\$)((?:[^$]+))(?:\$\$\$))$/;
|
||||
@ -34,7 +34,7 @@ export const MathBlock = Node.create({
|
||||
|
||||
addAttributes() {
|
||||
return {
|
||||
katex: {
|
||||
text: {
|
||||
default: "",
|
||||
parseHTML: (element) => element.innerHTML.split("$")[1],
|
||||
},
|
||||
@ -56,7 +56,7 @@ export const MathBlock = Node.create({
|
||||
return [
|
||||
"div",
|
||||
{},
|
||||
["div", { "data-katex": true }, `$${HTMLAttributes.katex}$`],
|
||||
["div", { "data-katex": true }, `$${HTMLAttributes.text}$`],
|
||||
];
|
||||
},
|
||||
|
||||
@ -65,7 +65,7 @@ export const MathBlock = Node.create({
|
||||
},
|
||||
|
||||
renderText({ node }) {
|
||||
return node.attrs.katex;
|
||||
return node.attrs.text;
|
||||
},
|
||||
|
||||
addCommands() {
|
||||
@ -87,7 +87,7 @@ export const MathBlock = Node.create({
|
||||
find: inputRegex,
|
||||
type: this.type,
|
||||
getAttributes: (match) => ({
|
||||
katex: match[1].replaceAll("$", ""),
|
||||
text: match[1].replaceAll("$", ""),
|
||||
}),
|
||||
}),
|
||||
];
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { Node, nodeInputRule, wrappingInputRule } from "@tiptap/core";
|
||||
import { Node, nodeInputRule } from "@tiptap/core";
|
||||
import { ReactNodeViewRenderer } from "@tiptap/react";
|
||||
|
||||
declare module "@tiptap/core" {
|
||||
@ -14,6 +14,10 @@ export interface MathInlineOption {
|
||||
view: any;
|
||||
}
|
||||
|
||||
export interface MathInlineAttributes {
|
||||
text: string;
|
||||
}
|
||||
|
||||
export const inputRegex = /(?:^|\s)((?:\$\$)((?:[^$]+))(?:\$\$))$/;
|
||||
|
||||
export const MathInline = Node.create<MathInlineOption>({
|
||||
@ -31,7 +35,7 @@ export const MathInline = Node.create<MathInlineOption>({
|
||||
|
||||
addAttributes() {
|
||||
return {
|
||||
katex: {
|
||||
text: {
|
||||
default: "",
|
||||
parseHTML: (element) => element.innerHTML.split("$")[1],
|
||||
},
|
||||
@ -53,12 +57,12 @@ export const MathInline = Node.create<MathInlineOption>({
|
||||
return [
|
||||
"div",
|
||||
{},
|
||||
["span", { "data-katex": true }, `$${HTMLAttributes.katex}$`],
|
||||
["span", { "data-katex": true }, `$${HTMLAttributes.text}$`],
|
||||
];
|
||||
},
|
||||
|
||||
renderText({ node }) {
|
||||
return node.attrs.katex;
|
||||
return node.attrs.text;
|
||||
},
|
||||
|
||||
addNodeView() {
|
||||
@ -84,7 +88,7 @@ export const MathInline = Node.create<MathInlineOption>({
|
||||
find: inputRegex,
|
||||
type: this.type,
|
||||
getAttributes: (match) => ({
|
||||
katex: match[1].replaceAll("$", ""),
|
||||
text: match[1].replaceAll("$", ""),
|
||||
}),
|
||||
}),
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user