Skip to content

Commit

Permalink
4.4.2
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
valentine195 committed Jun 3, 2021
1 parent 48b89b4 commit 2d463c6
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
4 changes: 2 additions & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -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> = {
Expand Down
12 changes: 6 additions & 6 deletions src/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand All @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit 2d463c6

Please sign in to comment.