'Monaco editor not executing custom formatter. (version 0.33.0)
I have made a example here
When I press right mouse click and then "Format Document", nothing happens.
I expected text to be changed to "test"
https://jsfiddle.net/y1v6hL4p/1/
require.config({ paths: { 'vs': 'https://unpkg.com/[email protected]/min/vs' }});
window.MonacoEnvironment = { getWorkerUrl: () => proxy };
let proxy = URL.createObjectURL(new Blob([`
self.MonacoEnvironment = {
baseUrl: 'https://unpkg.com/[email protected]/min/'
};
importScripts('https://unpkg.com/[email protected]/min/vs/base/worker/workerMain.js');
`], { type: 'text/javascript' }));
require(["vs/editor/editor.main"], function () {
monaco.languages.registerDocumentFormattingEditProvider("html", {
provideDocumentFormattingEdits(model, options) {
return [
{
range: model.getFullModelRange(),
text: 'test',
},
];
},
});
let editor = monaco.editor.create(document.getElementById('container'), {
value: [
'<Area>',
'</Area>'
].join('\n'),
language: 'html',
theme: 'vs-dark'
});
editor.addListener('didType', () => {
console.log(editor.getValue());
});
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
