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 the beta markdown editor #4

Merged
merged 4 commits into from
Mar 23, 2024

Conversation

personalizedrefrigerator
Copy link
Contributor

@personalizedrefrigerator personalizedrefrigerator commented Mar 22, 2024

Summary

Adds support for the beta markdown editor.

Specifically, this pull request:

  1. Updates the plugin build script to support importing CodeMirror 6 packages (the new build script is copied from the plugin template, see the editor plugin tutorial for details).
    • Upgrading the build script also required upgrading the dependencies in package.json to newer versions. The new versions were taken from the plugin template.
    • Types in api/ were not updated.
    • Because changes to package-lock.json are often difficult to review, changes to package-lock.json were not committed.
  2. Splits the current index.js content script into two content scripts — one for CodeMirror 5 and one for CodeMirror 6.

Notes

  • The CodeMirror 5 plugin seems to include additional logic for indenting lists. This logic was not included in the CodeMirror 6 plugin.
  • This pull request also adds support for Joplin for Android — I've verified that this plugin 1) can be loaded in a custom build of Joplin 3.0.1 and 2) can be used to switch the "increase indent" button between adding spaces and adding tabs.

Testing

This pull request has been tested manually by:

  1. Enabling the beta editor
  2. Creating an opening <style> tag
  3. Pressing enter
  4. Verifying that the new line is indented with spaces
  5. Changing the indentation setting from spaces to tabs in settings
  6. Repeating steps 2-3 and verifying that the new line is indented with tabs.
  7. Disabling "smart indent"
  8. Creating an opening <style> tag and pressing enter
  9. Verifying that the new line is not indented.
  10. Indenting by pressing tab
  11. Pressing enter and verifying that the new line is indented to match the previous.
  12. Changing "how many spaces should a block be indented" to 8
  13. Creating a list and indenting an item by pressing tab
  14. Verifying that the new item is indented with 2 tabs
  15. Disabling tab indentation
  16. Repeating step 13 and verifying that indentation uses 8 spaces

Steps 2-11 were also tested in the legacy CodeMirror 5 editor.

Note: The above testing was done on Ubuntu 22.04 with Joplin 2.14.20. I have also verified that the modified version of the plugin can be used to enable space indentation in Joplin 2.11.11 with default settings.

import type { IndentSettings } from "../settings";
import type { PluginContext } from "./types";

export default function(context: PluginContext) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

codeMirror5.ts is a version of indent.js, migrated to TypeScript and disabled in the CodeMirror 6 (beta markdown) editor.

@alondmnt
Copy link
Owner

Thanks a lot!

@alondmnt alondmnt merged commit c51ce30 into alondmnt:main Mar 23, 2024
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