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

CodeMirror 6 / beta editor support #93

Merged
merged 10 commits into from
Oct 2, 2024
Merged

CodeMirror 6 / beta editor support #93

merged 10 commits into from
Oct 2, 2024

Conversation

alondmnt
Copy link
Contributor

  • Tested on desktop
  • Tested on mobile

@cqroot cqroot added the enhancement New feature or request label Mar 29, 2024
Comment on lines 7 to 29
plugin: (editorControl: any) => {
if (!editorControl.cm6) { return; }

// Running in CM6
editorControl.registerCommand('scrollToLine', (lineNumber: number) => {
const editor: EditorView = editorControl.editor;
console.log('scrollToLine', lineNumber);

// Bounds checking
if (lineNumber < 0) {
lineNumber = 0;
}
if (lineNumber > editor.state.doc.lines) {
lineNumber = editor.state.doc.lines;
}

// Scroll to line, place the line at the *top* of the editor
const lineInfo = editor.state.doc.line(lineNumber);
editor.dispatch(editor.state.update({
effects: EditorView.scrollIntoView(lineInfo.from, {y: 'start'})
}));
});
},

Choose a reason for hiding this comment

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

@alondmnt This currently uses mixed tabs and space indentation.

(Thank you for working on this!)

Also note that if upgrading the plugin API proves to be too big of a change for this pull request, it should be possible to require CodeMirror 6 modules (with no types) with joplin.require. For example,

const { EditorView } = joplin.require('@codemirror/view');

Copy link
Contributor Author

@alondmnt alondmnt Apr 18, 2024

Choose a reason for hiding this comment

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

Thanks, missed those tabs (fixed).

Also accidentally installed @codemirror/view not as a dev dependency (fixed).

As for the joplin.require trick (thanks!), I had an issue with it so left it as is for now. If you or cqroot feel that this is necessary will try to resolve it.

cqroot and others added 2 commits May 3, 2024 17:32

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
refactor: fix eslint error
@cqroot cqroot merged commit 93e2f91 into cqroot:main Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants