forked from microsoft/vscode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for markdown notebook renderers (microsoft#115191)
* Use shared webpack version instead of installing locally for simple-browser * Use npm for building markdown preview * render markdown in webview. * update markdown preview height and offset * Add basic custom notebook renderer point * update css * style update. * update markdown header padding left * Add example of loading katex to extend the markdown-it renderer * Rename global to make clear it only applies to markdown-in * hide/remove markdown preview * Add wait for initial markdown preview rendering before showing notebook * Add double click to switch to editing mode * Fix markdown cells not getting updated after editing * style polish * notebook.experimental.useMarkdownRenderer * switch render strategy. * Adding very intial drag drop support for notebook markdown cells * Implement drag/drop stubs for test classes * Revert unrelated file changes * Move markdown notebook math to own extension * Add missing imports Co-authored-by: rebornix <penn.lv@gmail.com>
- Loading branch information
Showing
31 changed files
with
2,433 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
964 changes: 964 additions & 0 deletions
964
extensions/markdown-language-features/notebook-out/index.js
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import * as MarkdownIt from 'markdown-it'; | ||
|
||
declare const acquireNotebookRendererApi: any; | ||
type extendMarkdownItFnType = ( | ||
(f: (md: MarkdownIt.MarkdownIt) => void) => void | ||
); | ||
|
||
(function () { | ||
const markdownIt = new MarkdownIt(); | ||
|
||
(globalThis as any).extendMarkdownIt = ((f: (md: MarkdownIt.MarkdownIt) => void) => { | ||
f(markdownIt); | ||
}) as extendMarkdownItFnType; | ||
|
||
const notebook = acquireNotebookRendererApi('notebookCoreTestRenderer'); | ||
|
||
notebook.onDidCreateMarkdown(({ element, content }: any) => { | ||
console.log('did create markdown cell'); | ||
const rendered = markdownIt.render(content); | ||
element.innerHTML = rendered; | ||
}); | ||
|
||
console.log('markdown-it'); | ||
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
entry: { | ||
index: './notebook/index.ts' | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.tsx?$/, | ||
use: 'ts-loader', | ||
exclude: /node_modules/ | ||
} | ||
] | ||
}, | ||
resolve: { | ||
extensions: ['.tsx', '.ts', '.js'] | ||
}, | ||
output: { | ||
filename: '[name].js', | ||
path: path.resolve(__dirname, 'notebook-out') | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
test/** | ||
test-workspace/** | ||
src/** | ||
tsconfig.json | ||
out/test/** | ||
out/** | ||
extension.webpack.config.js | ||
extension-browser.webpack.config.js | ||
cgmanifest.json | ||
yarn.lock | ||
preview-src/** | ||
webpack.config.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Markdown Notebook Math support | ||
|
||
**Notice:** This extension is bundled with Visual Studio Code. It can be disabled but not uninstalled. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
import type * as markdownIt from 'markdown-it'; | ||
|
||
import 'katex/dist/katex.min.css'; | ||
|
||
declare const extendMarkdownIt: undefined | ( | ||
(f: (md: markdownIt.MarkdownIt) => void) => void | ||
); | ||
|
||
(function () { | ||
const katex = require('@iktakahiro/markdown-it-katex'); | ||
|
||
if (typeof extendMarkdownIt !== 'undefined') { | ||
extendMarkdownIt((md: markdownIt.MarkdownIt) => { | ||
md.use(katex); | ||
}); | ||
} | ||
}()); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"extends": "../../shared.tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "./dist/", | ||
"jsx": "react", | ||
"lib": [ | ||
"es2018", | ||
"DOM", | ||
"DOM.Iterable" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"name": "markdown-notebook-math", | ||
"displayName": "%displayName%", | ||
"description": "%description%", | ||
"version": "1.0.0", | ||
"icon": "icon.png", | ||
"publisher": "vscode", | ||
"enableProposedApi": true, | ||
"license": "MIT", | ||
"aiKey": "AIF-d9b70cd4-b9f9-4d70-929b-a071c400b217", | ||
"engines": { | ||
"vscode": "^1.54.0" | ||
}, | ||
"categories": [ | ||
"Other" | ||
], | ||
"contributes": { | ||
"notebookMarkdownRenderer": [ | ||
{ | ||
"id": "markdownItRenderer-katex", | ||
"displayName": "Markdown it renderer", | ||
"entrypoint": "./notebook-out/extension.js" | ||
} | ||
] | ||
}, | ||
"scripts": { | ||
"compile": "npm run build-notebook", | ||
"watch": "npm run build-notebook", | ||
"build-notebook": "npx webpack-cli --config webpack.notebook.js --mode production" | ||
}, | ||
"dependencies": { | ||
"@iktakahiro/markdown-it-katex": "^4.0.1" | ||
}, | ||
"devDependencies": { | ||
"@types/markdown-it": "^0.0.0", | ||
"css-loader": "^5.0.2", | ||
"markdown-it": "^12.0.4", | ||
"style-loader": "^2.0.0", | ||
"url-loader": "^4.1.1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/microsoft/vscode.git" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"displayName": "Markdown Notebook math", | ||
"description": "Provides rich language support for Markdown." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
entry: { | ||
extension: './notebook/extension.ts', | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.tsx?$/, | ||
use: 'ts-loader', | ||
exclude: /node_modules/ | ||
}, | ||
{ | ||
test: /\.css$/i, | ||
use: ['style-loader', 'css-loader'], | ||
}, | ||
{ | ||
test: /\.(woff|woff2|eot|ttf|otf)$/i, | ||
use: ['url-loader?limit=100000'] | ||
}, | ||
], | ||
}, | ||
resolve: { | ||
extensions: ['.tsx', '.ts', '.js'] | ||
}, | ||
output: { | ||
filename: '[name].js', | ||
path: path.resolve(__dirname, 'notebook-out') | ||
} | ||
}; |
Oops, something went wrong.