Skip to content

Commit

Permalink
Fix Quick Links conflict with other autocomplete plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
personalizedrefrigerator committed Feb 27, 2024
1 parent a6ef4ee commit 856412f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/contentScript/codeMirror6Plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type * as CodeMirrorStateType from '@codemirror/state';

import type { CompletionContext, CompletionResult, Completion } from '@codemirror/autocomplete';
import type { EditorView } from '@codemirror/view';
import type { Extension } from '@codemirror/state';

import { PluginContext } from './types';

Expand Down Expand Up @@ -93,10 +94,22 @@ export default function codeMirror6Plugin(pluginContext: PluginContext, CodeMirr
};
};

let extension: Extension;

if (CodeMirror.joplinExtensions) {
extension = CodeMirror.joplinExtensions.completionSource(completeMarkdown);
} else {
// The override field doesn't work if there are multiple
// plugins that try to use autocomplete. As such, only use it
// if the Joplin autocomplete extension isn't available.
extension = autocompletion({
override: [ completeMarkdown ],
});
}

CodeMirror.addExtension([
extension,
autocompletion({
activateOnTyping: true,
override: [ completeMarkdown ],
tooltipClass: () => 'quick-links-completions',
}),
]);
Expand Down

0 comments on commit 856412f

Please sign in to comment.