I’m setting up PM to be able to easily edit and render math (using http://mathquill.com/ ). I created a custom node type that uses a contained text
node to persist the latex generated by mathquill. Here’s the spec:
const mqSpec : NodeSpec = {
inline: true,
group: "inline",
content: "text*",
selectable: true,
toDOM: () => {
return ["span", {"mathquill": true}, 0]
},
parseDOM: [{
tag: "span[mathquill]"
}]
}
I discovered an issue today, however. When I place the cursor directly after the node and type a (non-return) character, I get the following state transition:
{
"doc": {
"type": "doc",
"content": [
{
"type": "paragraph",
"content": [
{
"type": "mq",
"content": [
{
"type": "text",
"text": "\\frac{\\sin x}{\\cos x}"
}
]
}
]
}
]
},
"selection": {
"head": 24,
"anchor": 24
}
}
{
"doc": {
"type": "doc",
"content": [
{
"type": "paragraph",
"content": [
{
"type": "mq",
"content": [
{
"type": "text",
"text": "sinxcosx"
}
]
},
{
"type": "text",
"text": " "
}
]
}
]
},
"selection": {
"head": 13,
"anchor": 13
}
}
As you can see, along with a new " " text node being inserted into the paragraph, it also seems that the content of the mq node gets changed. It looks like it’s maybe getting escaped.
I’m wondering if this is an expected behavior that I need to account for somehow? Or if this is perhaps unexpected behavior that should be filed as a bug.
Thanks!