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 plugin API: Multiple plugins can't register autocompletion sources without enabling CodeMirror's built-in autocomplete #9964

Closed
personalizedrefrigerator opened this issue Feb 20, 2024 · 0 comments · Fixed by #9965
Labels
beta-editor About the desktop beta editor desktop All desktop platforms enhancement Feature requests and code enhancements plugins Anything related to Joplin's plugin system

Comments

@personalizedrefrigerator
Copy link
Collaborator

personalizedrefrigerator commented Feb 20, 2024

Operating system

Linux

Joplin version

≥2.14.6

Current behaviour

See https://discuss.codemirror.net/t/autocompletion-merging-override-in-config/7853/2.

At present, CodeMirror 6 content scripts can register custom completions as follows:

const customCompletion = completeFromList([ 'completion1', 'completion2' ]);
editorControl.addExtension([
    autocompletion(),
    EditorState.languageData.of(() => [{ autocomplete: customCompletion }]),
]);

The above, however, enables CodeMirror's built-in autocompletions (e.g. autocompleting function in JavaScript code blocks or HTML tags in markdown), which may not be desired.

An alternative is something similar to this:

const customCompletion = completeFromList([ 'completion1', 'completion2' ]);
editorControl.addExtension([
    autocompletion({ overrides: [customCompletion] }),
]);

However, this fails if more than one plugin tries to register completions this way.

Expected behavior

Multiple plugins should be able to add autocompletion sources without enabling CodeMirror's built-in autocomplete.

@personalizedrefrigerator personalizedrefrigerator added enhancement Feature requests and code enhancements desktop All desktop platforms plugins Anything related to Joplin's plugin system beta-editor About the desktop beta editor labels Feb 20, 2024
laurent22 pushed a commit that referenced this issue Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-editor About the desktop beta editor desktop All desktop platforms enhancement Feature requests and code enhancements plugins Anything related to Joplin's plugin system
Projects
None yet
1 participant