mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 16:15:41 +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
|
|
@ -52,6 +52,7 @@ Options can be passed in to `MonacoWebpackPlugin`. They can be used to generate
|
|||
* default value: `['apex', 'azcli', 'bat', 'clojure', 'coffee', 'cpp', 'csharp', 'csp', 'css', 'dockerfile', 'fsharp', 'go', 'handlebars', 'html', 'ini', 'java', 'javascript', 'json', 'less', 'lua', 'markdown', 'msdax', 'mysql', 'objective', 'perl', 'pgsql', 'php', 'postiats', 'powerquery', 'powershell', 'pug', 'python', 'r', 'razor', 'redis', 'redshift', 'ruby', 'rust', 'sb', 'scheme', 'scss', 'shell', 'solidity', 'sql', 'st', 'swift', 'typescript', 'vb', 'xml', 'yaml']`.
|
||||
* `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']`.
|
||||
* excluded features: It is also possible to exclude certain default features prefixing them with an exclamation mark '!'.
|
||||
|
||||
## Contributing
|
||||
|
||||
|
|
|
|||
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),
|
||||
|
|
|
|||
1364
package-lock.json
generated
1364
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -16,6 +16,6 @@ module.exports = {
|
|||
}]
|
||||
},
|
||||
plugins: [
|
||||
new MonacoWebpackPlugin()
|
||||
new MonacoWebpackPlugin({features: ['!contextmenu']})
|
||||
]
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue