Skip to content
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

Support CodeMirror 6 #7

Merged
merged 3 commits into from
Mar 15, 2024

Conversation

personalizedrefrigerator
Copy link
Contributor

@personalizedrefrigerator personalizedrefrigerator commented Feb 29, 2024

Summary

Adds support for Joplin's beta CodeMirror 6-based markdown editor (see the Joplin plugin tutorial).

To do this, it,

  1. Works around an issue in the CodeMirror compatibility layer (.getDoc is undefined)
  2. Updates the plugin build script to allow importing @codemirror/ packages at runtime.
  3. Registers keyboard commands with a CodeMirror 6 extension when in CodeMirror 6.

Notes

  • Does not commit changes to package-lock.json.
  • CodeMirror 6 plugin support requires Joplin >= 2.14.6.

Testing

  1. Enable the beta editor
  2. Create a new 3x3 table with header using the toolbar button
  3. Fill each of the cells (navigate using tab)
  4. Navigate back to the beginning of the table with shift-tab
  5. Minify the table using the menu item
  6. Undo the minification
  7. Click on the second-to-last row
  8. Add a new line using ctrl-enter
  9. Add a new column using the toolbar button.
  10. Align the column to the left
  11. Align the column to the right
  12. Repeat for the legacy CodeMirror 5 editor.

This has been tested successfully in Joplin 2.14.16 on Ubuntu 23.10.

table-tools-screen-recording.mp4

@personalizedrefrigerator
Copy link
Contributor Author

personalizedrefrigerator commented Mar 1, 2024

There might be import issues in older versions of Joplin -- converting to a draft for now.

Edit: This should be fixed --- CodeMirror 6 imports have been converted to dynamic requires that will only be used when running in Joplin's beta markdown editor.

@personalizedrefrigerator personalizedrefrigerator marked this pull request as draft March 1, 2024 06:13
@personalizedrefrigerator personalizedrefrigerator marked this pull request as ready for review March 1, 2024 16:11
@FelisDiligens FelisDiligens changed the base branch from main to develop March 15, 2024 17:33
@FelisDiligens FelisDiligens merged commit 1ca19fa into FelisDiligens:develop Mar 15, 2024
@FelisDiligens
Copy link
Owner

Hi @personalizedrefrigerator,

thanks for the PR! And sorry for taking so long to respond.
The code looks fine to me and works on Joplin 2.14.19 on my side. I merged it into the develop branch and will push an update within the next days. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants