Skip to content

Commit f394ac7

Browse files
authored
Added back alert styling for markdown cells (#167)
* Revert "Revert "Add styles for jupyter markdown alerts (#143)"" This reverts commit e9afbfe. * add alert box styling through markdown-style class template * revert file rename, remove unneeded style tag * remove markdown preview styles
1 parent 9f7b95a commit f394ac7

File tree

4 files changed

+103
-0
lines changed

4 files changed

+103
-0
lines changed

build/webpack/webpack.client.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const defaultConfig = {
5656
context: constants.ExtensionRootDir,
5757
entry: {
5858
renderers: './src/client/index.tsx',
59+
markdown: './src/client/markdown.ts',
5960
builtinRendererHooks: './src/client/builtinRendererHooks.ts',
6061
vegaRenderer: './src/client/vegaRenderer.ts'
6162
},

package-lock.json

Lines changed: 45 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,14 @@
117117
"application/vnd.vegalite.v4+json",
118118
"application/vnd.vegalite.v5+json"
119119
]
120+
},
121+
{
122+
"id": "jupyter-markdown",
123+
"displayName": "Jupyter Markdown styles",
124+
"entrypoint": {
125+
"extends": "vscode.markdown-it-renderer",
126+
"path": "./out/client_renderer/markdown.js"
127+
}
120128
}
121129
]
122130
},
@@ -189,6 +197,7 @@
189197
"@types/glob": "^7.1.1",
190198
"@types/loadable__component": "^5.10.0",
191199
"@types/lodash": "^4.14.158",
200+
"@types/markdown-it": "^12.2.3",
192201
"@types/mocha": "^7.0.2",
193202
"@types/node": "^12.11.7",
194203
"@types/react": "^16.9.35",

src/client/markdown.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
const styleContent = `
7+
.alert {
8+
width: auto;
9+
padding: 1em;
10+
margin-top: 1em;
11+
margin-bottom: 1em;
12+
border-style: solid;
13+
border-width: 1px;
14+
}
15+
.alert > *:last-child {
16+
margin-bottom: 0;
17+
}
18+
#preview > .alert:last-child {
19+
/* Prevent this being set to zero by the default notebook stylesheet */
20+
padding-bottom: 1em;
21+
}
22+
23+
.alert-success {
24+
background-color: rgb(200,230,201);
25+
color: rgb(27,94,32);
26+
}
27+
.alert-info {
28+
background-color: rgb(178,235,242);
29+
color: rgb(0,96,100);
30+
}
31+
.alert-warning {
32+
background-color: rgb(255,224,178);
33+
color: rgb(230,81,0);
34+
}
35+
.alert-danger {
36+
background-color: rgb(255,205,210);
37+
color: rgb(183,28,28);
38+
}
39+
`;
40+
41+
export async function activate() {
42+
const style = document.createElement('style');
43+
style.textContent = styleContent;
44+
const template = document.createElement('template');
45+
template.classList.add('markdown-style');
46+
template.content.appendChild(style);
47+
document.head.appendChild(template);
48+
}

0 commit comments

Comments
 (0)