-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KaTeX Integration #179
Comments
Maybe you could see how it's implemented here. Since I don't want to implement it, I will close the ticket. |
@wngu6 Were you able to figure out how to do this? |
I've implemented a working prototype for inline math. You may have to add additional css to get it working as depicted here. https://gist.github.com/BrianHung/b72126c98fa08cb1c09170b1394771a0 Edit I've also implemented a working prototype for mathblocks. You'd have to figure out how to get the arrow_handler to work properly but mostly seems functional. https://gist.github.com/BrianHung/60efde8536f3fa76334f759c33a741e5 |
@BrianHung can you explain how to use the katex inline extension? |
@BrianHung Thanks for the gist. But when I try to render by typing
This is what I've done. I think that's enough. Is there anything else that I've missed ? Update:
Is there any code sandbox where it is implemented, I can compare these two and that might fix the error. |
Detecting whether a cursor leaves or enter an inline node is harder than detecting whether it leaves a block-level node like a paragraph. See https://discuss.prosemirror.net/t/prosemirror-math-at-desmos/707/8. I would recommend getting comfortable with ProseMirror's plugin system first: https://prosemirror.net/docs/ref/#state.Plugin_System. |
pheww.... I figured it out. finally. parentHasSelection() {
.....
// decides whether the anchor is between the Math node or not
const hasAnchor = this.getPos() < anchor && anchor < this.getPos() + this.node.nodeSize
...
...
// some other cases where it is necessary like when the editor is out of focus OR displaying in non-editable mode.
// I removed the selection as it doesn't change anything when I paste the math. It is adding extra $ at both ends. Don't know
// why.
return hasAnchor && this.view.focused && this.view.editable @BrianHung if possible, could you please update the gist with this logic with some changes if required. And if you have time, please add comments so that we understand what is going on. It saves lot of time. |
And, for mathblock.js too, we need to change few things Otherwise it won't work properly. ...
computed: {
visibleClass() {
return this.hasProseMirrorSelection() ? "active" : "hidden"
},
},
... And this hasProseMirrorSelection() {
let anchor = this.view.state.selection.anchor
const hasAnchor = this.getPos() <= anchor && anchor < this.node.nodeSize + this.getPos()
return hasAnchor && this.view.focused && this.view.editable
}, Hope these are updated in the gist so that others won't face this issue. |
@ramsane @BrianHung hello. I'm no expert but I managed to use different extension except this one. Could you provide a sandbox or a working exemple ? I can't figure why it doesnt work for me. I'd love to be able to add maths to a project. |
Hi, did anyone know an alternative when you work in React ? Didn't find any so far 😔 |
@AdminScientificHub |
It would be great if there was an extension that uses KaTeX, sort of like Dropbox Paper but better.
There should be one for inline mode and another for display mode. When editing maths, especially for display mode, it would be great if it allows multiple lines.
This is my attempt in display math mode.
I modeled it after
Iframe.js
.The text was updated successfully, but these errors were encountered: