Skip to content

Commit

Permalink
fix: reduced margin on content inside admonitions without titles (close
Browse files Browse the repository at this point in the history
  • Loading branch information
valentine195 committed Feb 18, 2022
1 parent 7034477 commit 643ca8e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
7 changes: 4 additions & 3 deletions src/assets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@
display: none;
}

.admonition > .admonition-title.no-title + .admonition-content-holder {
margin-top: 1rem;
margin-bottom: 1rem;
.admonition-plugin.no-title .admonition-content-holder,
.admonition-plugin.no-title .admonition-content-holder > .admonition-content {
margin-top: 0;
margin-bottom: 0;
}

.admonition-content-holder {
Expand Down
18 changes: 13 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ ${editor.getDoc().getSelection()}
if (checking) return admonition.command;
if (admonition.command) {
try {
const title = admonition.title ?? ""
const title = admonition.title ?? "";
editor.getDoc().replaceSelection(
`\`\`\`ad-${admonition.type}
title: ${title}
Expand Down Expand Up @@ -1269,7 +1269,9 @@ ${editor.getDoc().getSelection()}\n--- admonition\n`
attrs.open = "open";
}
admonition = createEl("details", {
cls: `admonition admonition-${type} admonition-plugin`,
cls: `admonition admonition-${type} admonition-plugin ${
!title?.trim().length ? "no-title" : ""
}`,
attr: attrs
});
titleEl = admonition.createEl("summary", {
Expand All @@ -1279,7 +1281,9 @@ ${editor.getDoc().getSelection()}\n--- admonition\n`
});
} else {
admonition = createDiv({
cls: `admonition admonition-${type} admonition-plugin`,
cls: `admonition admonition-${type} admonition-plugin ${
!title?.trim().length ? "no-title" : ""
}`,
attr: attrs
});
titleEl = admonition.createDiv({
Expand Down Expand Up @@ -1391,7 +1395,9 @@ ${editor.getDoc().getSelection()}\n--- admonition\n`
attrs.open = "open";
}
admonition = createEl("details", {
cls: `admonition admonition-${type} admonition-plugin admonition-plugin-async`,
cls: `admonition admonition-${type} admonition-plugin admonition-plugin-async ${
!title?.trim().length ? "no-title" : ""
}`,
attr: attrs
});
titleEl = admonition.createEl("summary", {
Expand All @@ -1401,7 +1407,9 @@ ${editor.getDoc().getSelection()}\n--- admonition\n`
});
} else {
admonition = createDiv({
cls: `admonition admonition-${type} admonition-plugin`,
cls: `admonition admonition-${type} admonition-plugin ${
!title?.trim().length ? "no-title" : ""
}`,
attr: attrs
});
titleEl = admonition.createDiv({
Expand Down

0 comments on commit 643ca8e

Please sign in to comment.