[html] add css support to html extension as library

This commit is contained in:
Martin Aeschlimann
2016-11-14 11:34:33 +01:00
parent 332fd57d3f
commit 8a85fc0399
17 changed files with 357 additions and 492 deletions

View File

@@ -5,7 +5,6 @@
'use strict';
import { window, workspace, DecorationOptions, DecorationRenderOptions, Disposable, Range, TextDocument, TextEditor } from 'vscode';
import { isEmbeddedContentUri, getHostDocumentUri } from './embeddedContentUri';
const MAX_DECORATORS = 500;
@@ -64,9 +63,8 @@ export function activateColorDecorations(decoratorProvider: (uri: string) => The
if (triggerUpdate) {
pendingUpdateRequests[documentUriStr] = setTimeout(() => {
// check if the document is in use by an active editor
let contentHostUri = isEmbeddedContentUri(documentUri) ? getHostDocumentUri(documentUri) : documentUriStr;
window.visibleTextEditors.forEach(editor => {
if (editor.document && contentHostUri === editor.document.uri.toString()) {
if (editor.document && documentUriStr === editor.document.uri.toString()) {
updateDecorationForEditor(editor, documentUriStr);
}
});

View File

@@ -1,27 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import { Uri } from 'vscode';
export const EMBEDDED_CONTENT_SCHEME = 'embedded-content';
export function isEmbeddedContentUri(virtualDocumentUri: Uri): boolean {
return virtualDocumentUri.scheme === EMBEDDED_CONTENT_SCHEME;
}
export function getEmbeddedContentUri(parentDocumentUri: string, embeddedLanguageId: string): Uri {
return new Uri().with({ scheme: EMBEDDED_CONTENT_SCHEME, authority: embeddedLanguageId, path: '/' + encodeURIComponent(parentDocumentUri) + '.' + embeddedLanguageId });
};
export function getHostDocumentUri(virtualDocumentUri: Uri): string {
let languageId = virtualDocumentUri.authority;
let path = virtualDocumentUri.path.substring(1, virtualDocumentUri.path.length - languageId.length - 1); // remove leading '/' and new file extension
return decodeURIComponent(path);
};
export function getEmbeddedLanguageId(virtualDocumentUri: Uri): string {
return virtualDocumentUri.authority;
}