-
Notifications
You must be signed in to change notification settings - Fork 336
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
How to add LaTeX or any math formula support to my HTML editor? #74
Comments
I don't know how LaTeX works in HTML, is there some JS/CSS you have to add? How would you add LaTeX support to a normal HTML document? This will help me figure out a way to support it in the editor. |
To add LaTex or MathJax, we only need to be able to add a script to the iframe head.
` http://docs.mathjax.org/en/latest/web/examples.html This code is obviously not a good approach but, it is working. |
Thanks for the detail, just noticed you are using Flutter Web. I know how to implement this and will provide a solution for you soon. |
@alirezaemami can you try this: HtmlEditor(
controller: controller,
htmlEditorOptions: HtmlEditorOptions(
initialText: r"""Look at this: \(ax^2 + bx + c = 0\) \(\sqrt{x}\)""",
darkMode: false,
webInitialScripts: UnmodifiableListView(
[
WebScript(script: """
var script = document.createElement('script');
script.src = 'https://polyfill.io/v3/polyfill.min.js?features=es6';
document.head.appendChild(script);
var script2 = document.createElement('script');
script2.src = 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js';
script2.async = true;
document.head.appendChild(script2);
""", name: "mathJax"
)
]
)
),
callbacks: Callbacks(onInit: () {
controller.evaluateJavascriptWeb("mathJax");
}),
), Let me know if it doesn't work or you need more help. Result: I will say this, I like the idea of editing math in the HTML editor but it wasn't really built for this... when I tried to mess around with creating math input it wasn't working. Maybe I was doing something wrong though, just FYI. |
Thank you for paying attention to this issue. I'm currently developing part of an online testing project called Wikiazma, and I want my users able to design complex questions freely. I need a WYSIWYG editor for this, but unfortunately, Flutter is still weak in this, and after reviewing dozens of libraries, HTML seems to work better than Markdown, Quill, and etc. |
Yes you are correct, the wysiwyg functionality in Flutter is very lacking, especially because their webview support is not great. Hopefully it gets better in the future. If you have any other questions feel free to ask. Thanks! |
void addText() {
controller.insertText(r"""Look at this: \(ax^2 + bx + c = 0\) \(\sqrt{x}\)""");
} This does not add expression to the editor. It just adds the given string as it is. is it possible to use Can you help please? |
I need to add LaTeX (or any other approach) to add formula in my HTML
The text was updated successfully, but these errors were encountered: