[sources] Add Vue SFC (Single File Component) syntax support.

This hooks up @codemirror/lang-vue provided syntax support for all *.vue
files.

Fixed: chromium:1385678
Bug: chromium:1385374
Change-Id: If8500b3928f95b91553bb047e032b49816eed806
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/4171288
Reviewed-by: Simon Zünd <szuend@chromium.org>
This commit is contained in:
Benedikt Meurer
2023-01-17 08:09:15 +00:00
parent 7e0ca66c29
commit df8814299d
4 changed files with 9 additions and 6 deletions
+1 -1
View File
@@ -563,5 +563,5 @@ export const mimeTypeByExtension = new Map([
['svelte', 'text/x.svelte'],
// Vue
['vue', 'text/html'],
['vue', 'text/x.vue'],
]);
@@ -166,6 +166,9 @@ export async function languageFromMIME(mimeType: string): Promise<CodeMirror.Lan
case 'text/x.svelte':
return (await CodeMirror.svelte()).svelte();
case 'text/x.vue':
return (await CodeMirror.vue()).vue();
default:
return null;
}
@@ -462,7 +462,7 @@ describe('ResourceType', () => {
});
it('returns correct MIME type for .vue files', () => {
assert.strictEqual(ResourceType.mimeFromExtension('vue'), 'text/html');
assert.strictEqual(ResourceType.mimeFromExtension('vue'), 'text/x.vue');
});
it('returns correct MIME type for .webmanifest files', () => {
@@ -527,7 +527,7 @@ describe('ResourceType', () => {
it('returns correct MIME type for .vue files', () => {
const url = 'http://localhost/App.vue' as Platform.DevToolsPath.UrlString;
assert.strictEqual(ResourceType.mimeFromURL(url), 'text/html');
assert.strictEqual(ResourceType.mimeFromURL(url), 'text/x.vue');
});
it('returns correct MIME type for .webmanifest files', () => {
@@ -120,10 +120,10 @@ it('can highlight Angular Templates', testHighlight(`
it('can highlight Vue Templates', testHighlight(`
<[tag template]>
<[tag Header] [attribute v-show]=[attribute-value "view"] />
<[tag Main] [attribute @hide]=[attribute-value "onHide"] />
<[tag Header] [keyword v-show]=[attribute-value "][variable view][attribute-value "] />
<[tag Main] @[variable hide]=[attribute-value "][variable onHide][attribute-value "] />
<[tag router-view] />
</[tag template]>`, 'text/html'));
</[tag template]>`, 'text/x.vue'));
it('can highlight CSS', testHighlight(`
[tag span].[type cls]#[atom id] {