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

Desktop: Improve beta editor support for the Rich Markdown plugin #9935

Conversation

personalizedrefrigerator
Copy link
Collaborator

@personalizedrefrigerator personalizedrefrigerator commented Feb 14, 2024

Summary

This pull request builds on the changes to the CodeMirror 5 emulation in #9928 to make more features of the Rich Markdown plugin work in the CodeMirror 6 beta editor.

Note

This pull request currently includes all changes from #9928.

It also requires this Rich Markdown pull request to be merged.

Specifically, it,

  1. Adds the CodeMirror class to the CodeMirror 6 editor. This allows existing Rich Markdown stylesheets to be applied to the editor.
    • Because CodeMirror 5 stylesheets are applied to .CodeMirror elements, this pull request adjusts several existing styles.
  2. Adds support for the styleActiveLine CodeMirror 5 option
  3. Support editor.addWidget
  4. Support editor.markText (originally from Desktop: Resolves #9927: Beta editor: Fix search results not highlighted #9928)
  5. Fixes defineExtension doesn't override existing extensions with the same name
  6. Adjust how coordsChar handles the page mode
  7. Adds the CodeMirror-line class to visible lines in the editor
  8. Fixes an issue with loading CodeMirror 6 content scripts that contain inline comments

This pull request still requires changes to the Rich Markdown plugin. A pull request will be opened shortly.

Testing

Regression testing (desktop):

  1. Open the welcome notes in the beta editor
  2. Verify that math is syntax highlighted
  3. Verify that tables have a monospaced font
  4. Verify that headers have a larger font size than non-headers
  5. Verify that changing the default editor font in settings changes the editor font
  6. Verify that changing the editor font size in settings changes the editor's font size

This has been successfully tested on Ubuntu 23.10.

Regression testing (mobile):

  1. Open the welcome notes
  2. Verify that math has syntax highlighting
  3. Verify that tables have a monospaced font
  4. Verify that headers have a larger size than nonheaders
  5. Verify that the editor's font size can be changed in settings

This has been tested successfully on Android 7.

@personalizedrefrigerator personalizedrefrigerator changed the title Desktop: Support the Rich Markdown plugin in the beta editor with minimal changes Desktop: Improve beta editor support for the Rich Markdown plugin Feb 14, 2024
@laurent22
Copy link
Owner

@personalizedrefrigerator, there's just one conflict and then we can merge

@@ -10,6 +10,8 @@ import { ViewPlugin, DecorationSet, ViewUpdate } from '@codemirror/view';
import { ensureSyntaxTree } from '@codemirror/language';
import { RangeSetBuilder } from '@codemirror/state';

const baseLineDecoration = Decoration.line({ class: 'CodeMirror-line' });
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

- <div class="cm-line">...</div>
+ <div class="cm-line CodeMirror-line">...</div>
  • Check which plugins need this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've removed the CodeMirror-line class — RichMarkdown only needs it in 1-2 places.

Other plugins like ReMoods seem to use it, but also rely on other CSS classes being present that we don't seem to have.

Comment on lines +101 to +106
'&.CodeMirror': {
height: 'unset',
background: 'unset',
overflow: 'unset',
direction: 'unset',
},
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Adding the .CodeMirror class to the editor makes it easier to migrate styles originally intended for CodeMirror 5. It does, however, mean that several CodeMirror 5 styles need to be overridden.

@laurent22
Copy link
Owner

Here as well, some more conflicts

@laurent22 laurent22 merged commit c35085d into laurent22:dev Mar 9, 2024
10 checks passed
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