After monaco multi-instance destroys one instance, another instance cannot get the content[Bug] #3686
Replies: 5 comments 1 reply
-
pls help me。。 |
Beta Was this translation helpful? Give feedback.
-
I think you misunderstood the issue. The issue is that commands are not linked to an editor but global even though you add them using an editor instance |
Beta Was this translation helpful? Give feedback.
-
Please help me how to solve this problem,tks |
Beta Was this translation helpful? Give feedback.
-
I suggest you use the const a = monaco.editor.create(document.getElementById('container'), {
value: "function hello() {\n\talert('Hello world!');\n}",
language: 'javascript'
});
a.addAction({
id: 'save',
label: 'Save',
keybindings: [monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyS],
run(editor) {
console.log(editor.getModel().id)
}
})
const b = monaco.editor.create(document.getElementById('container2'), {
value: "function hello() {\n\talert('Hello world!');\n}",
language: 'javascript'
});
b.addAction({
id: 'save',
label: 'Save',
keybindings: [monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyS],
run(editor) {
console.log(editor.getModel().id)
}
})
document.getElementById('dispose').onclick = () => {
b.dispose();
} |
Beta Was this translation helpful? Give feedback.
-
Can anyone tell how to remove action in reactjs |
Beta Was this translation helpful? Give feedback.
-
Reproducible in vscode.dev or in VS Code Desktop?
Reproducible in the monaco editor playground?
Monaco Editor Playground Code
js
Beta Was this translation helpful? Give feedback.
All reactions