This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The reason will be displayed to describe this comment to others. Learn more.
Possible issue
Using override seems to mean that this won't work well with other CM6 autocompletion plugins (like the CodeMirror 6 snippets plugin). For example, if another plugin enables code block autocompletion, this will disable it.
By default, autocompletion gets completions from the languageData defined at the cursor. For example, if the cursor is in a JavaScript code block, the user will get JavaScript completions.
The above adds global language data that provides autocompletions from completeMarkdown.
The issue with this is that autocompletion() enables completion from languageData, so users will also get completions in code blocks (which might not be desirable).
Example with the above change:
Screencast.from.2024-01-19.14-40-54.webm
The user may not want autocompletion within code blocks, however.
Alternative 2
Add a setting ("show suggestions from other sources") to switch between the current implementation and alternative 1.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The reason will be displayed to describe this comment to others. Learn more.
Changes to webpack.config.js are copied from the upstream joplin-generator package.
These changes are required to prevent Webpack from duplicating CodeMirror 6 packages (which would cause the extension not to work because globals from one copy are not equal to globals from copy 2).
console.warn(chalk.yellow(`WARNING: To publish the plugin, the package name should start with "joplin-plugin-" (found "${content.name}") in ${packageJsonPath}`));
}
Expand DownExpand Up
@@ -67,15 +82,48 @@ function currentGitInfo() {
}
}
functionvalidateCategories(categories){
if(!categories)returnnull;
if((categories.length!==newSet(categories).size))thrownewError('Repeated categories are not allowed');
// eslint-disable-next-line github/array-foreach -- Old code before rule was applied
categories.forEach(category=>{
if(!allPossibleCategories.map(category=>{returncategory.name;}).includes(category))thrownewError(`${category} is not a valid category. Please make sure that the category name is lowercase. Valid categories are: \n${allPossibleCategories.map(category=>{returncategory.name;})}\n`);
});
}
functionvalidateScreenshots(screenshots){
if(!screenshots)returnnull;
for(constscreenshotofscreenshots){
if(!screenshot.src)thrownewError('You must specify a src for each screenshot');
// Avoid attempting to download and verify URL screenshots.
if(!allPossibleScreenshotsType.includes(screenshotType))thrownewError(`${screenshotType} is not a valid screenshot type. Valid types are: \n${allPossibleScreenshotsType}\n`);
console.warn(chalk.yellow(`Version numbers have been updated but they do not match: package.json (${packageJson.version}), manifest.json (${manifest.version}). Set them to the required values to get them in sync.`));
}
};
constconfigName=argv['joplin-plugin-config'];
functionmain(environ){
constconfigName=environ['joplin-plugin-config'];
if(!configName)thrownewError('A config file must be specified via the --joplin-plugin-config flag');
// Webpack configurations run in parallel, while we need them to run in
Expand DownExpand Up
@@ -260,22 +369,30 @@ function main(processArgv) {
fs.mkdirpSync(publishDir);
}
if(configName==='updateVersion'){
updateVersion();
return[];
}
returnconfigs[configName];
}
letexportedConfigs=[];
try{
exportedConfigs=main(process.argv);
}catch(error){
console.error(chalk.red(error.message));
process.exit(1);
}
module.exports=(env)=>{
letexportedConfigs=[];
if(!exportedConfigs.length){
// Nothing to do - for example where there are no external scripts to
// compile.
process.exit(0);
}
try{
exportedConfigs=main(env);
}catch(error){
console.error(error.message);
process.exit(1);
}
module.exports=exportedConfigs;
if(!exportedConfigs.length){
// Nothing to do - for example where there are no external scripts to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible issue
Using
overrideseems to mean that this won't work well with other CM6 autocompletion plugins (like the CodeMirror 6 snippets plugin). For example, if another plugin enables code block autocompletion, this will disable it.Alternative 1
Here's an alternative:
By default,
autocompletiongets completions from thelanguageDatadefined at the cursor. For example, if the cursor is in a JavaScript code block, the user will get JavaScript completions.The above adds global language data that provides autocompletions from
completeMarkdown.The issue with this is that
autocompletion()enables completion fromlanguageData, so users will also get completions in code blocks (which might not be desirable).Example with the above change:
Screencast.from.2024-01-19.14-40-54.webm
The user may not want autocompletion within code blocks, however.
Alternative 2
Add a setting ("show suggestions from other sources") to switch between the current implementation and alternative 1.
The code might then look like this: