Skip to content

Commit

Permalink
Merge 8cadb0b into eb033b3
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean-Stilwell authored Oct 3, 2023
2 parents eb033b3 + 8cadb0b commit bb55b29
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Portal/src/Datahub.Core/Components/DHMarkdown.razor
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
var module = await _jsRuntime.InvokeAsync<IJSObjectReference>("import",
"./_content/Datahub.Core/Components/DHMarkdown.razor.js");
await module.InvokeVoidAsync("styleCodeblocks", _elementReference);

await module.InvokeVoidAsync("addStyleSheetRule", ".markdown-content .mud-typography { margin-bottom: 1em!important; margin-top: 1em!important; }");
}

}
19 changes: 19 additions & 0 deletions Portal/src/Datahub.Core/Components/DHMarkdown.razor.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,23 @@ function toggleClassList(el, classes = []){
classes.forEach(name => {
el.classList.toggle(name);
})
}

let ruleAdded = false;

export function addStyleSheetRule(rule) {
if (!ruleAdded) {
var stylesheet = document.createElement("style");
stylesheet.type = "text/css";
document.head.appendChild(stylesheet);

if (stylesheet.sheet) {
if (stylesheet.sheet.insertRule) {
stylesheet.sheet.insertRule(rule, 0);
} else if (stylesheet.sheet.addRule) {
stylesheet.sheet.addRule(rule.split("{")[0].trim(), rule.split("{")[1].trim(), 0);
}
}
}
ruleAdded = true;
}

0 comments on commit bb55b29

Please sign in to comment.