mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-25 15:35:43 +01:00
Render checkboxes in markdown (#200846)
Fixes microsoft/vscode-pull-request-github#5310
This commit is contained in:
@@ -1817,6 +1817,7 @@ export const basicMarkupHtmlTags = Object.freeze([
|
||||
'hr',
|
||||
'i',
|
||||
'img',
|
||||
'input',
|
||||
'ins',
|
||||
'kbd',
|
||||
'label',
|
||||
|
||||
@@ -388,9 +388,26 @@ function sanitizeRenderedMarkdown(
|
||||
}
|
||||
e.keepAttr = false;
|
||||
return;
|
||||
} else if (element.tagName === 'INPUT' && element.attributes.getNamedItem('type')?.value === 'checkbox') {
|
||||
if ((e.attrName === 'type' && e.attrValue === 'checkbox') || e.attrName === 'disabled' || e.attrName === 'checked') {
|
||||
e.keepAttr = true;
|
||||
return;
|
||||
}
|
||||
e.keepAttr = false;
|
||||
}
|
||||
});
|
||||
|
||||
dompurify.addHook('uponSanitizeElement', (element, e) => {
|
||||
if (e.tagName === 'input') {
|
||||
if (element.attributes.getNamedItem('type')?.value === 'checkbox') {
|
||||
element.setAttribute('disabled', '');
|
||||
} else {
|
||||
element.parentElement?.removeChild(element);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
const hook = DOM.hookDomPurifyHrefAndSrcSanitizer(allowedSchemes);
|
||||
|
||||
try {
|
||||
@@ -405,10 +422,12 @@ export const allowedMarkdownAttr = [
|
||||
'align',
|
||||
'autoplay',
|
||||
'alt',
|
||||
'checked',
|
||||
'class',
|
||||
'controls',
|
||||
'data-code',
|
||||
'data-href',
|
||||
'disabled',
|
||||
'draggable',
|
||||
'height',
|
||||
'href',
|
||||
@@ -420,6 +439,7 @@ export const allowedMarkdownAttr = [
|
||||
'style',
|
||||
'target',
|
||||
'title',
|
||||
'type',
|
||||
'width',
|
||||
'start',
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user