Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 24 additions & 10 deletions src/callout/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,21 +273,35 @@ export default class CalloutManager extends Component {
setUseSnippet() {
if (this.plugin.data.useSnippet) {
this.updateSnippet();
} else {
this.plugin.app.customCss.setCssEnabledStatus(
this.plugin.data.snippetPath,
false
);
this.plugin.app.customCss.readSnippets();
if (this.plugin.data.snippetPath) {
this.plugin.app.vault.adapter
.remove(this.snippetPath)
.catch(() => {
// File may already not exist; ignore
});
}
}
}
async updateSnippet() {
if (!this.plugin.data.useSnippet) return;
if (await this.plugin.app.vault.adapter.exists(this.snippetPath)) {
await this.plugin.app.vault.adapter.write(
this.snippetPath,
this.generateCssString()
);
} else {
await this.plugin.app.vault.create(
this.snippetPath,
this.generateCssString()
);
const snippetPath = this.snippetPath;
const snippetsDir = snippetPath.substring(
0,
snippetPath.lastIndexOf("/")
);
if (!(await this.plugin.app.vault.adapter.exists(snippetsDir))) {
await this.plugin.app.vault.adapter.mkdir(snippetsDir);
}
await this.plugin.app.vault.adapter.write(
snippetPath,
this.generateCssString()
);
this.plugin.app.customCss.setCssEnabledStatus(
this.plugin.data.snippetPath,
true
Expand Down
2 changes: 1 addition & 1 deletion src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export default class AdmonitionSetting extends PluginSettingTab {
new Setting(admonitionEl)
.setName("Use CSS Snippet for Custom Callouts")
.setDesc(
"Instead of managing it internally, Admonitions will maintain a CSS snippet to enable your custom types for callouts."
"Instead of managing it internally, Admonitions will maintain a CSS snippet to enable your custom types for callouts. Required for correct rendering in popout windows."
)
.addToggle((t) =>
t.setValue(this.plugin.data.useSnippet).onChange((v) => {
Expand Down