From 2d463c680180bcbfbcd5ad877aa144c09a94b614 Mon Sep 17 00:00:00 2001 From: valentine195 <38669521+valentine195@users.noreply.github.com> Date: Thu, 3 Jun 2021 15:53:37 -0400 Subject: [PATCH] 4.4.2 - Custom admonitions that have commands registered will now properly unregister those commands when deleted - Command icons are now symbols to prevent unintentional collisions with other plugin icons - Additional container CSS is now explicitly for the admonition plugin --- manifest.json | 2 +- package.json | 2 +- src/constants.ts | 4 ++-- src/main.css | 12 ++++++------ src/main.ts | 8 ++++++-- src/settings.ts | 6 +++--- versions.json | 2 +- 7 files changed, 20 insertions(+), 16 deletions(-) diff --git a/manifest.json b/manifest.json index 970ac03..d0f22ca 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-admonition", "name": "Admonition", - "version": "4.4.1", + "version": "4.4.2", "minAppVersion": "0.11.0", "description": "Admonition block-styled content for Obsidian.md", "author": "Jeremy Valentine", diff --git a/package.json b/package.json index 473d19e..1311002 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-admonition", - "version": "4.4.1", + "version": "4.4.2", "description": "Admonition block-styled content for Obsidian.md", "main": "main.js", "scripts": { diff --git a/src/constants.ts b/src/constants.ts index 76d826a..161182e 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,10 +1,10 @@ import { Admonition } from "../@types/types"; export const ADD_ADMONITION_COMMAND_ICON = ``; -export const ADD_COMMAND_NAME = "add-admonition-command-icon"; +export const ADD_COMMAND_NAME = Symbol("add-command"); export const REMOVE_ADMONITION_COMMAND_ICON = ``; -export const REMOVE_COMMAND_NAME = "remove-admonition-command-icon"; +export const REMOVE_COMMAND_NAME = Symbol("remove-command"); export const ADMONITION_MAP: Record = { diff --git a/src/main.css b/src/main.css index 2ecfe70..3843e29 100644 --- a/src/main.css +++ b/src/main.css @@ -127,28 +127,28 @@ details.admonition[open] > summary > .collapser > .handle { } /** Settings */ -.additional-container > .setting-item:not(.setting-item-heading) { +.admonition-setting-additional-container > .setting-item:not(.setting-item-heading) { border: 0px; } -.additional-container { +.admonition-setting-additional-container { border-bottom: 1px solid var(--background-modifier-border); border-top: 1px solid var(--background-modifier-border); padding: 18px 0 0 0; } -.additional-container > .setting-item-heading:only-child { +.admonition-setting-additional-container > .setting-item-heading:only-child { padding-bottom: 18px; } -.additional-container > .additional { +.admonition-setting-additional-container > .additional { margin: 6px 12px; } -.additional-container > .additional > .setting-item { +.admonition-setting-additional-container > .additional > .setting-item { border-top: 0; padding-top: 9px; } -.additional-container +.admonition-setting-additional-container > .additional > .setting-item > .setting-item-control diff --git a/src/main.ts b/src/main.ts index b3d086f..6de6252 100644 --- a/src/main.ts +++ b/src/main.ts @@ -143,6 +143,10 @@ export default class ObsidianAdmonition this.turnOffSyntaxHighlighting([admonition.type]); } + if (admonition.command) { + this.unregisterCommandsFor(admonition); + } + await this.saveSettings(); } async onload(): Promise { @@ -152,8 +156,8 @@ export default class ObsidianAdmonition this.addSettingTab(new AdmonitionSetting(this.app, this)); - addIcon(ADD_COMMAND_NAME, ADD_ADMONITION_COMMAND_ICON); - addIcon(REMOVE_COMMAND_NAME, REMOVE_ADMONITION_COMMAND_ICON); + addIcon(ADD_COMMAND_NAME.toString(), ADD_ADMONITION_COMMAND_ICON); + addIcon(REMOVE_COMMAND_NAME.toString(), REMOVE_ADMONITION_COMMAND_ICON); Object.keys(this.admonitions).forEach((type) => { this.registerMarkdownCodeBlockProcessor( diff --git a/src/settings.ts b/src/settings.ts index a57f79a..d576e9e 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -129,7 +129,7 @@ export default class AdmonitionSetting extends PluginSettingTab { }); const additionalContainer = containerEl.createDiv( - "additional-container" + "admonition-setting-additional-container" ); new Setting(additionalContainer) .setName("Add New") @@ -176,7 +176,7 @@ export default class AdmonitionSetting extends PluginSettingTab { if (!admonition.command) { setting.addExtraButton((b) => { - b.setIcon(ADD_COMMAND_NAME) + b.setIcon(ADD_COMMAND_NAME.toString()) .setTooltip("Register Commands") .onClick(async () => { this.plugin.registerCommandsFor(admonition); @@ -186,7 +186,7 @@ export default class AdmonitionSetting extends PluginSettingTab { }); } else { setting.addExtraButton((b) => { - b.setIcon(REMOVE_COMMAND_NAME) + b.setIcon(REMOVE_COMMAND_NAME.toString()) .setTooltip("Unregister Commands") .onClick(async () => { this.plugin.unregisterCommandsFor(admonition); diff --git a/versions.json b/versions.json index 10a44a0..8f44681 100644 --- a/versions.json +++ b/versions.json @@ -9,5 +9,5 @@ "4.1.7": "0.11.0", "4.2.1": "0.11.0", "4.3.1": "0.12.0", - "4.4.1": "0.12.2" + "4.4.2": "0.12.2" } \ No newline at end of file