mirror of
https://github.com/docmost/docmost.git
synced 2026-05-25 12:04:35 +08:00
Make math node handling better
This commit is contained in:
@@ -36,7 +36,9 @@ export const MathBlock = Node.create({
|
|||||||
return {
|
return {
|
||||||
text: {
|
text: {
|
||||||
default: "",
|
default: "",
|
||||||
parseHTML: (element) => element.innerHTML.split("$")[1],
|
parseHTML: (element) => {
|
||||||
|
return element.innerHTML;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -44,7 +46,7 @@ export const MathBlock = Node.create({
|
|||||||
parseHTML() {
|
parseHTML() {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
tag: "div",
|
tag: `div[data-type="${this.name}"]`,
|
||||||
getAttrs: (node: HTMLElement) => {
|
getAttrs: (node: HTMLElement) => {
|
||||||
return node.hasAttribute("data-katex") ? {} : false;
|
return node.hasAttribute("data-katex") ? {} : false;
|
||||||
},
|
},
|
||||||
@@ -55,8 +57,8 @@ export const MathBlock = Node.create({
|
|||||||
renderHTML({ HTMLAttributes }) {
|
renderHTML({ HTMLAttributes }) {
|
||||||
return [
|
return [
|
||||||
"div",
|
"div",
|
||||||
{},
|
{ "data-type": this.name, "data-katex": true },
|
||||||
["div", { "data-katex": true }, `$$${HTMLAttributes.text}$$`],
|
`${HTMLAttributes.text}`,
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,9 @@ export const MathInline = Node.create<MathInlineOption>({
|
|||||||
return {
|
return {
|
||||||
text: {
|
text: {
|
||||||
default: "",
|
default: "",
|
||||||
parseHTML: (element) => element.innerHTML.split("$")[1],
|
parseHTML: (element) => {
|
||||||
|
return element.innerHTML;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -45,7 +47,7 @@ export const MathInline = Node.create<MathInlineOption>({
|
|||||||
parseHTML() {
|
parseHTML() {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
tag: "span",
|
tag: `span[data-type="${this.name}"]`,
|
||||||
getAttrs: (node: HTMLElement) => {
|
getAttrs: (node: HTMLElement) => {
|
||||||
return node.hasAttribute("data-katex") ? {} : false;
|
return node.hasAttribute("data-katex") ? {} : false;
|
||||||
},
|
},
|
||||||
@@ -54,7 +56,11 @@ export const MathInline = Node.create<MathInlineOption>({
|
|||||||
},
|
},
|
||||||
|
|
||||||
renderHTML({ HTMLAttributes }) {
|
renderHTML({ HTMLAttributes }) {
|
||||||
return ["span", { "data-katex": true }, `$${HTMLAttributes.text}$` || {}];
|
return [
|
||||||
|
"span",
|
||||||
|
{ "data-type": this.name, "data-katex": true },
|
||||||
|
`${HTMLAttributes.text}`,
|
||||||
|
];
|
||||||
},
|
},
|
||||||
|
|
||||||
addNodeView() {
|
addNodeView() {
|
||||||
|
|||||||
Reference in New Issue
Block a user