Merge pull request #37 from nicoabie/exclude-features

Feature exclude
This commit is contained in:
Alexandru Dima 2018-09-20 10:45:00 +02:00 committed by GitHub
commit 1bd93df64b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 713 additions and 677 deletions

View file

@ -63,6 +63,7 @@ Some languages share the same web worker. If one of the following languages is i
* `features` (`string[]`) - include only a subset of the editor features. * `features` (`string[]`) - include only a subset of the editor features.
* default value: `['accessibilityHelp', 'bracketMatching', 'caretOperations', 'clipboard', 'codeAction', 'codelens', 'colorDetector', 'comment', 'contextmenu', 'coreCommands', 'cursorUndo', 'dnd', 'find', 'folding', 'fontZoom', 'format', 'goToDefinitionCommands', 'goToDefinitionMouse', 'gotoError', 'gotoLine', 'hover', 'inPlaceReplace', 'inspectTokens', 'iPadShowKeyboard', 'linesOperations', 'links', 'multicursor', 'parameterHints', 'quickCommand', 'quickOutline', 'referenceSearch', 'rename', 'smartSelect', 'snippets', 'suggest', 'toggleHighContrast', 'toggleTabFocusMode', 'transpose', 'wordHighlighter', 'wordOperations', 'wordPartOperations']`. * default value: `['accessibilityHelp', 'bracketMatching', 'caretOperations', 'clipboard', 'codeAction', 'codelens', 'colorDetector', 'comment', 'contextmenu', 'coreCommands', 'cursorUndo', 'dnd', 'find', 'folding', 'fontZoom', 'format', 'goToDefinitionCommands', 'goToDefinitionMouse', 'gotoError', 'gotoLine', 'hover', 'inPlaceReplace', 'inspectTokens', 'iPadShowKeyboard', 'linesOperations', 'links', 'multicursor', 'parameterHints', 'quickCommand', 'quickOutline', 'referenceSearch', 'rename', 'smartSelect', 'snippets', 'suggest', 'toggleHighContrast', 'toggleTabFocusMode', 'transpose', 'wordHighlighter', 'wordOperations', 'wordPartOperations']`.
* excluded features: It is also possible to exclude certain default features prefixing them with an exclamation mark '!'.
## Contributing ## Contributing

View file

@ -28,10 +28,31 @@ const languagesById = fromPairs(
); );
const featuresById = mapValues(FEATURES, (feature, key) => mixin({ label: key }, feature)) 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 { class MonacoWebpackPlugin {
constructor(options = {}) { constructor(options = {}) {
const languages = options.languages || Object.keys(languagesById); const languages = options.languages || Object.keys(languagesById);
const features = options.features || Object.keys(featuresById); const features = getFeaturesIds(options.features || [], featuresById);
const output = options.output || ''; const output = options.output || '';
this.options = { this.options = {
languages: languages.map((id) => languagesById[id]).filter(Boolean), languages: languages.map((id) => languagesById[id]).filter(Boolean),

1364
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -16,6 +16,6 @@ module.exports = {
}] }]
}, },
plugins: [ plugins: [
new MonacoWebpackPlugin() new MonacoWebpackPlugin({features: ['!contextmenu']})
] ]
}; };