Skip to content

Update maths to use tiptap vs custom implementation for latex#7978

Merged
mejo- merged 8 commits intonextcloud:mainfrom
moodyjmz:chore(-wrench-)--Update-maths-to-use-tiptap-vs-custom-implementation-for-latex
Nov 29, 2025
Merged

Update maths to use tiptap vs custom implementation for latex#7978
mejo- merged 8 commits intonextcloud:mainfrom
moodyjmz:chore(-wrench-)--Update-maths-to-use-tiptap-vs-custom-implementation-for-latex

Conversation

@moodyjmz
Copy link
Copy Markdown
Contributor

@moodyjmz moodyjmz commented Nov 24, 2025

📝 Summary

Summary

Migrated the mathematics nodes to use the official @tiptap/extension-mathematics package instead of our custom
implementation. This brings us in line with Tiptap while maintaining all existing functionality.

Changes Made

Core Migration

  • Extended Tiptap's math nodes instead of building from scratch (src/nodes/Mathematics.js)
    • Used .extend() pattern to customize BlockMath and InlineMath nodes
    • Added VueNodeViewRenderer to keep our Vue component UI
    • Followed the same pattern as CodeBlock and Image nodes

Backward Compatibility

  • Added parseHTML rules to handle KaTeX HTML from markdown-it
    • When loading markdown files, $E=mc^2$ gets converted to KaTeX HTML by markdown-it
    • Our custom rules extract the LaTeX from tags so it parses correctly
    • This ensures existing markdown files with math formulas load properly

Bug Fixes

  • Fixed inline math pushing to new line (src/nodes/MathematicsView.vue)
    • Removed space from <span ref="mathEl"> </span> that was causing line breaks
    • Cleaned up modal rendering with v-if instead of wrapper div
    • Inline formulas now stay inline as expected

Menu Updates

  • Updated menu commands to use new Tiptap signatures (src/components/Menu/entries.js)
    • Changed node names: math_inline >>> inlineMath, math_block >>> blockMath
    • Updated command calls to use object parameters: insertInlineMath({ latex })
    • Fixed menu actions to access editor state correctly

Tests

  • Updated all test expectations (src/tests/nodes/Mathematics.spec.js)
    • Changed node name assertions to match new Tiptap names
    • Updated command calls to use new signatures
    • All 20 tests passing ✅

What Still Works

  • Modal editing with auto-open for empty formulas
  • Both inline and block math rendering
  • Markdown roundtrip (load and save)
  • All existing UI/UX unchanged from user perspective

🖼️ Screenshots

🏚️ Before 🏡 After
B A

🚧 TODO

  • ...

🏁 Checklist

  • Code is properly formatted (npm run lint / npm run stylelint / composer run cs:check)
  • Sign-off message is added to all commits
  • Tests (unit, integration and/or end-to-end) passing and the changes are covered with tests
  • Documentation (README or documentation) has been updated or is not required

@moodyjmz
Copy link
Copy Markdown
Contributor Author

@mejo- I think this should address the issues you mentioned, sans the inline menu question

@juliusknorr juliusknorr added bug Something isn't working 3. to review labels Nov 25, 2025
@codecov
Copy link
Copy Markdown

codecov bot commented Nov 25, 2025

Codecov Report

❌ Patch coverage is 70.58824% with 15 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/components/Menu/entries.js 0.00% 8 Missing and 4 partials ⚠️
src/nodes/Mathematics.js 94.73% 2 Missing ⚠️
src/nodes/MathematicsView.vue 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@mejo- mejo- force-pushed the chore(-wrench-)--Update-maths-to-use-tiptap-vs-custom-implementation-for-latex branch from d0fd0be to fd51ee4 Compare November 25, 2025 16:00
Copy link
Copy Markdown
Member

@mejo- mejo- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and works really well now!

Thanks so much for going the extra mile to address all the issues @moodyjmz 🙏

I pushed a small commit to make prettier happy.

@mejo- mejo- force-pushed the chore(-wrench-)--Update-maths-to-use-tiptap-vs-custom-implementation-for-latex branch from fd51ee4 to a558595 Compare November 25, 2025 16:12
@mejo-
Copy link
Copy Markdown
Member

mejo- commented Nov 25, 2025

For some reason some playwright tests fail reliably now 🤔

moodyjmz and others added 8 commits November 29, 2025 11:58
…g pattern

Signed-off-by: James Manuel <moodyjmz@users.noreply.github.com>
Signed-off-by: James Manuel <moodyjmz@users.noreply.github.com>
Signed-off-by: James Manuel <moodyjmz@users.noreply.github.com>
Signed-off-by: James Manuel <moodyjmz@users.noreply.github.com>
Signed-off-by: James Manuel <moodyjmz@users.noreply.github.com>
Signed-off-by: James Manuel <moodyjmz@users.noreply.github.com>
Signed-off-by: Jonas <jonas@freesources.org>
Fixes opening the smart picker when typing `/`.

Signed-off-by: Jonas <jonas@freesources.org>
@mejo- mejo- force-pushed the chore(-wrench-)--Update-maths-to-use-tiptap-vs-custom-implementation-for-latex branch from a558595 to cd165ff Compare November 29, 2025 11:17
@mejo-
Copy link
Copy Markdown
Member

mejo- commented Nov 29, 2025

For some reason some playwright tests fail reliably now 🤔

Found the reason and pushed a fix. the editor property to action callback in menu is not always passed, so the callback needs to take this into account.

When CI runs through now I will merge. Thanks again @moodyjmz for the contribution, much appreciated 🙏

@mejo- mejo- merged commit 9be6ca4 into nextcloud:main Nov 29, 2025
63 checks passed
@moodyjmz
Copy link
Copy Markdown
Contributor Author

That's great! Thanks for finding the issue and fixing it

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Dec 9, 2025

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bugs with new mathematics node types

3 participants