fix: enable prettier formatter for umd (#2)

This commit is contained in:
Peng Xiao 2020-01-30 04:15:37 +08:00 committed by GitHub
parent 549e4afc5a
commit 1b31f48186
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 1 deletions

View file

@ -30,6 +30,7 @@
'vs/basic-languages': '../node_modules/monaco-languages/release/dev',
'vs/language/yaml': '../lib/dev',
vs: '../node_modules/monaco-editor-core/dev/vs',
prettier: '../node_modules/prettier',
};
if (document.location.protocol === 'http:') {
// Add support for running local http server
@ -51,6 +52,8 @@
require([
'vs/basic-languages/monaco.contribution',
'vs/language/yaml/monaco.contribution',
'prettier/standalone',
'prettier/parser-yaml',
], function() {
const yaml = `p1: `;
const modelUri = monaco.Uri.parse('a://b/foo.json');
@ -68,6 +71,7 @@
hover: true,
completion: true,
validate: true,
format: true,
schemas: [
{
uri: 'http://myserver/foo-schema.json', // id of the first schema

View file

@ -35,11 +35,12 @@ export class YAMLFormatter {
try {
const prettier = require('prettier/standalone');
const parser = require('prettier/parser-yaml');
const text = document.getText();
const formatted = prettier.format(
text,
Object.assign(options, { parser: 'yaml' })
Object.assign(options, { parser: 'yaml', plugins: [parser] })
);
return [

2
src/monaco.d.ts vendored
View file

@ -40,6 +40,8 @@ declare namespace monaco.languages.yaml {
* Whether or not kubernetes yaml is supported
*/
readonly isKubernetes?: boolean;
readonly format?: boolean;
}
export interface LanguageServiceDefaults {