mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 09:08:48 +01:00
enable markdown extension API
This commit is contained in:
@@ -199,11 +199,6 @@
|
||||
"default": true,
|
||||
"description": "%markdown.preview.doubleClickToSwitchToEditor.desc%"
|
||||
},
|
||||
"markdown.enableExperimentalExtensionApi": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "%markdown.preview.enableExperimentalExtensionApi.desc%"
|
||||
},
|
||||
"markdown.trace": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
|
||||
@@ -13,6 +13,5 @@
|
||||
"markdown.showSource.title" : "Show Source",
|
||||
"markdown.styles.dec": "A list of URLs or local paths to CSS style sheets to use from the markdown preview. Relative paths are interpreted relative to the folder open in the explorer. If there is no open folder, they are interpreted relative to the location of the markdown file. All '\\' need to be written as '\\\\'.",
|
||||
"markdown.showPreviewSecuritySelector.title": "Change Markdown Preview Security Settings",
|
||||
"markdown.preview.enableExperimentalExtensionApi.desc": "[Experimental] Allow extensions to extend the markdown preview.",
|
||||
"markdown.trace.desc": "Enable debug logging for the markdown extension."
|
||||
}
|
||||
@@ -54,49 +54,42 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
const contentProvider = new MDDocumentContentProvider(engine, context, cspArbiter, logger);
|
||||
const contentProviderRegistration = vscode.workspace.registerTextDocumentContentProvider('markdown', contentProvider);
|
||||
const previewSecuritySelector = new PreviewSecuritySelector(cspArbiter, contentProvider);
|
||||
if (vscode.workspace.getConfiguration('markdown').get('enableExperimentalExtensionApi', false)) {
|
||||
for (const extension of vscode.extensions.all) {
|
||||
const contributes = extension.packageJSON && extension.packageJSON.contributes;
|
||||
if (!contributes) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let styles = contributes['markdown.previewStyles'];
|
||||
if (styles) {
|
||||
if (!Array.isArray(styles)) {
|
||||
styles = [styles];
|
||||
}
|
||||
for (const style of styles) {
|
||||
try {
|
||||
contentProvider.addStyle(resolveExtensionResources(extension, style));
|
||||
} catch (e) {
|
||||
// noop
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const extension of vscode.extensions.all) {
|
||||
const contributes = extension.packageJSON && extension.packageJSON.contributes;
|
||||
if (!contributes) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let scripts = contributes['markdown.previewScripts'];
|
||||
if (scripts) {
|
||||
if (!Array.isArray(scripts)) {
|
||||
scripts = [scripts];
|
||||
}
|
||||
for (const script of scripts) {
|
||||
try {
|
||||
contentProvider.addScript(resolveExtensionResources(extension, script));
|
||||
} catch (e) {
|
||||
// noop
|
||||
}
|
||||
const styles = contributes['markdown.previewStyles'];
|
||||
if (styles && Array.isArray(styles)) {
|
||||
for (const style of styles) {
|
||||
try {
|
||||
contentProvider.addStyle(resolveExtensionResources(extension, style));
|
||||
} catch (e) {
|
||||
// noop
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (contributes['markdownit.plugins']) {
|
||||
extension.activate().then(() => {
|
||||
if (extension.exports && extension.exports.extendMarkdownIt) {
|
||||
engine.addPlugin((md: any) => extension.exports.extendMarkdownIt(md));
|
||||
}
|
||||
});
|
||||
const scripts = contributes['markdown.previewScripts'];
|
||||
if (scripts && Array.isArray(scripts)) {
|
||||
for (const script of scripts) {
|
||||
try {
|
||||
contentProvider.addScript(resolveExtensionResources(extension, script));
|
||||
} catch (e) {
|
||||
// noop
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (contributes['markdown.markdownItPlugins']) {
|
||||
extension.activate().then(() => {
|
||||
if (extension.exports && extension.exports.extendMarkdownIt) {
|
||||
engine.addPlugin((md: any) => extension.exports.extendMarkdownIt(md));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const symbolsProvider = new MDDocumentSymbolProvider(engine);
|
||||
|
||||
Reference in New Issue
Block a user