mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 20:52:56 +01:00
Add ability to exclude certain default features by prefixing them with an exclamation mark
This commit is contained in:
parent
2f7821f494
commit
97fa344ed9
4 changed files with 713 additions and 677 deletions
23
index.js
23
index.js
|
|
@ -28,10 +28,31 @@ const languagesById = fromPairs(
|
|||
);
|
||||
const featuresById = mapValues(FEATURES, (feature, key) => mixin({ label: key }, feature))
|
||||
|
||||
function getFeaturesIds(userFeatures, predefinedFeaturesById) {
|
||||
function notContainedIn(arr) {
|
||||
return (element) => arr.indexOf(element) === -1;
|
||||
}
|
||||
|
||||
let featuresIds;
|
||||
|
||||
if (userFeatures.length) {
|
||||
const excludedFeatures = userFeatures.filter(f => f[0] === '!').map(f => f.slice(1));
|
||||
if (excludedFeatures.length) {
|
||||
featuresIds = Object.keys(predefinedFeaturesById).filter(notContainedIn(excludedFeatures))
|
||||
} else {
|
||||
featuresIds = userFeatures;
|
||||
}
|
||||
} else {
|
||||
featuresIds = Object.keys(predefinedFeaturesById);
|
||||
}
|
||||
|
||||
return featuresIds;
|
||||
}
|
||||
|
||||
class MonacoWebpackPlugin {
|
||||
constructor(options = {}) {
|
||||
const languages = options.languages || Object.keys(languagesById);
|
||||
const features = options.features || Object.keys(featuresById);
|
||||
const features = getFeaturesIds(options.features || [], featuresById);
|
||||
const output = options.output || '';
|
||||
this.options = {
|
||||
languages: languages.map((id) => languagesById[id]).filter(Boolean),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue