microsoft / microsoft/monaco-editor
How could I make an context menu disabled not hide
Open
Nobody has claimed this yet.
contextmenu
feature-request
- Dominant language
- JavaScript
- Stars
- 46.8k
- Forks
- 4.1k
- Avg merge
- 17h 58m
- Merged PRs (30d)
- 1
Description
Hi all,
how could I make Redo in a disable style, not hide it?
my code:
this.undo = this.editor.createContextKey('undo', false);
this.redo = this.editor.createContextKey('redo', false);
this.editor.addAction({
id: 'undo_model',
label: 'Undo',
keybindings: [
monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_Z
],
contextMenuGroupId: '9_cutcopypaste',
contextMenuOrder: 0,
precondition: 'undo',
run: () => {
this.editor.trigger('', 'undo');
},
});
this.editor.addAction({
id: 'redo_model',
label: 'Redo',
keybindings: [
monaco.KeyMod.CtrlCmd | monaco.KeyMod.Shift | monaco.KeyCode.KEY_Z
],
contextMenuGroupId: '9_cutcopypaste',
contextMenuOrder: 0,
precondition: 'redo',
run: () => {
this.editor.trigger('', 'redo');
},
});
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the behavior in the linked Monaco Playground using editor.createContextKey and editor.addAction with the undo and redo preconditions. Inspect how a false precondition affects the context menu. Done means the Redo action remains visible but disabled when redo is false.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100