joplin-math-mode icon indicating copy to clipboard operation
joplin-math-mode copied to clipboard

Draft: Native CodeMirror 6 support

Open personalizedrefrigerator opened this issue 7 months ago • 0 comments

Summary

At present, the Math Mode plugin doesn't work well in the CodeMirror 6-based beta editor. This pull request refactors the CodeMirror plugin to:

  1. Use CodeMirror 6 APIs when running in CodeMirror 6
  2. Use CodeMirror 5 APIs when running in CodeMirror 5.

Previously, CodeMirror 6 support was provided by Joplin's compatibility layer.

Why avoid the compatibility layer?

  • Bugs
    • Currently, only the last line of math seems to be rendered correctly.
    • Issues with selection and inline results.
  • The compatibility layer may be removed in the future.

Notes and resources

To-do

  • [ ] Improve refresh logic — currently, math isn't refreshed in some cases:
    • [ ] Adding a configuration line to a math block.
    • [ ] Converting a math block to a different type of code block.
  • [ ] Remove changes to package-lock.json from this pull request — such changes are often difficult to review and can be made separately.
  • [ ] Refactoring, code cleanup, and documentation
    • Consider taking the approach outlined in the [CodeMirror 5 compatibility documentation]((https://joplinapp.org/help/api/tutorials/cm6_plugin#codemirror-5-compatibility), where the CodeMirror 5 and CodeMirror 6 content scripts are bundled separately by Webpack. At present, CodeMirror 6
  • [ ] More manual testing.