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 = `<svg viewBox="0 0 100 100" class="add-admonition-command"><path fill="currentColor" stroke="currentColor" d="M37,16c-4.4,0-8.3,3.3-9.2,7.6l-11.6,52c-0.5,2.2,0,4.3,1.2,5.9c1.2,1.6,3.2,2.6,5.4,2.6H79c4.4,0,8.3-3.3,9.2-7.6 l11.6-52c0.5-2.2,0-4.3-1.2-5.9C97.4,17,95.4,16,93.2,16L37,16z M37,20h56.2c1.1,0,1.8,0.4,2.2,1c0.5,0.6,0.7,1.4,0.4,2.6l-1,4.4 H30.8l0.8-3.6C32.1,22.2,34.8,20,37,20z M29.9,32H94l-9.6,43.6C83.9,77.8,81.2,80,79,80H22.8c-1.1,0-1.8-0.4-2.2-1 c-0.5-0.6-0.7-1.4-0.4-2.6L29.9,32z M0,36v4h19.6l0.9-4L0,36z M36.7,38c-0.8,0.1-1.4,0.7-1.6,1.5l-3.5,14c-0.2,0.6,0,1.2,0.4,1.7 c0.4,0.5,1,0.8,1.6,0.8H81c0.9,0,1.7-0.6,1.9-1.5l3.5-14c0.2-0.6,0-1.3-0.4-1.8c-0.4-0.5-1-0.8-1.6-0.8H37.1c-0.1,0-0.1,0-0.2,0 C36.9,38,36.8,38,36.7,38L36.7,38z M38.7,42h43.2l-2.4,10H36.2L38.7,42z M0,52v4h16l0.9-4H0z M0,68v4h12.4l0.9-4H0z"></path><circle fill="white" transform="translate(50 50) scale(3 3)" cx="8" cy="8" r="8"/><path fill="green" transform="translate(50 50) scale(3 3)" d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM8.5 4.5a.5.5 0 0 0-1 0v3h-3a.5.5 0 0 0 0 1h3v3a.5.5 0 0 0 1 0v-3h3a.5.5 0 0 0 0-1h-3v-3z"/></svg>`; -export const ADD_COMMAND_NAME = "add-admonition-command-icon"; +export const ADD_COMMAND_NAME = Symbol("add-command"); export const REMOVE_ADMONITION_COMMAND_ICON = `<svg viewBox="0 0 100 100" class="remove-admonition-command"><path fill="currentColor" stroke="currentColor" d="M37,16c-4.4,0-8.3,3.3-9.2,7.6l-11.6,52c-0.5,2.2,0,4.3,1.2,5.9c1.2,1.6,3.2,2.6,5.4,2.6H79c4.4,0,8.3-3.3,9.2-7.6 l11.6-52c0.5-2.2,0-4.3-1.2-5.9C97.4,17,95.4,16,93.2,16L37,16z M37,20h56.2c1.1,0,1.8,0.4,2.2,1c0.5,0.6,0.7,1.4,0.4,2.6l-1,4.4 H30.8l0.8-3.6C32.1,22.2,34.8,20,37,20z M29.9,32H94l-9.6,43.6C83.9,77.8,81.2,80,79,80H22.8c-1.1,0-1.8-0.4-2.2-1 c-0.5-0.6-0.7-1.4-0.4-2.6L29.9,32z M0,36v4h19.6l0.9-4L0,36z M36.7,38c-0.8,0.1-1.4,0.7-1.6,1.5l-3.5,14c-0.2,0.6,0,1.2,0.4,1.7 c0.4,0.5,1,0.8,1.6,0.8H81c0.9,0,1.7-0.6,1.9-1.5l3.5-14c0.2-0.6,0-1.3-0.4-1.8c-0.4-0.5-1-0.8-1.6-0.8H37.1c-0.1,0-0.1,0-0.2,0 C36.9,38,36.8,38,36.7,38L36.7,38z M38.7,42h43.2l-2.4,10H36.2L38.7,42z M0,52v4h16l0.9-4H0z M0,68v4h12.4l0.9-4H0z"></path><circle fill="white" transform="translate(50 50) scale(3 3)" cx="8" cy="8" r="8"/><path fill="#dc3545" transform="translate(50 50) scale(3 3)" d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM4.5 7.5a.5.5 0 0 0 0 1h7a.5.5 0 0 0 0-1h-7z"/></svg>`; -export const REMOVE_COMMAND_NAME = "remove-admonition-command-icon"; +export const REMOVE_COMMAND_NAME = Symbol("remove-command"); export const ADMONITION_MAP: Record<string, Admonition> = { 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<void> { @@ -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