Skip to content

Commit

Permalink
6.0.0
Browse files Browse the repository at this point in the history
6.0.0 Release

- Added ability to define admonitions without using a code block
- Added `.admonition-plugin` class to top level element
- Add command to "Insert Admonition" with a modal chooser
- Add command to "Replace Admonitions with HTML"
  • Loading branch information
valentine195 authored Jun 22, 2021
2 parents 3d37aad + 448e71a commit 6521c0b
Show file tree
Hide file tree
Showing 9 changed files with 814 additions and 46 deletions.
82 changes: 81 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod nulla.
```
````

Please note that as of **4.4.1**, the `title` and `collapse` parameters must be at the *top* of the block, in any order.
Please note that as of **4.4.1**, the `title` and `collapse` parameters must be at the _top_ of the block, in any order.

### Titles

Expand Down Expand Up @@ -330,6 +330,76 @@ An icon without a title will have this CSS:
}
```

## Global Commands

Several commands are available for the plugin by default.

### Collapse and Open All Admonitions In Note

If these two commands are triggered with an open note, all collapsible admonitions will be collapsed or open respectively.

### Replace Admonitions With HTML

Replace _all_ admonition source blocks with the rendered HTML in the note content.

This command will overwrite all Admonitions in the open note.

### Insert Admonition

This will open a modal where the admonition type, title and collapse behavior can be set, then the generated admonition code block will be inserted into the open editor.

### Admonition-specific commands

Commands may be registered for each custom admonition type to insert them into an open note by clicking the `Register Commands` button.

See [this section](#register-and-unregister-commands) for more information.

## Non-code block Admonitions

As of version 6.0.0, there is a new setting: Enable Non-codeblock Admonitions.

This setting is highly experimental and may not work as expected, and there are a few caveats listed at the end of this section to keep in mind.

This setting allows for creating an admonition without wrapping it in a code block, which means that links and tags will sync into Obsidian's cache. A non-codeblock admonition may be created using the following syntax:

```
!!! ad-<type> Title goes here!
content
--- admonition
```

This will create the appropriate admonition type, embed the content, and give it the supplied title.

A collapsible admonition may be created using the following syntax:

```
??? ad-<type> Title goes here!
content
--- admonition
```

A collapsible admonition may default to "open" by appending a +:

```
???+ ad-<type> Title goes here!
content
--- admonition
```

### Caveats

1. Changing to admonition content after render require the cache to be cleared. The note must be closed and re-opened (and sometimes, a different note must be opened first).
2. Nested admonitions are not currently supported.
3. Empty titles are not currently supported.

If you experience any bugs using this setting, please create an issue and I will look into them.

## Settings

### Syntax Highlighting
Expand All @@ -342,6 +412,10 @@ This will attempt to sync internal links within admonitions to the metadata cach

This setting is experimental and could have unintended consequences. If you begin to experience odd behavior, try turning it off and reloading Obsidian.

### Enable Non-codeblock Admonitions

Allow use of non-codeblock admonitions, described [here](#non-code-block-admonitions).

### Collapsible By Default

Admonitions will be automatically rendered as collapsible (open) by default.
Expand Down Expand Up @@ -382,6 +456,12 @@ No additional features are planned at this time. If there is a feature missing t

# Version History

## 6.0.0
- Added ability to define admonitions without using a code block
- Added `.admonition-plugin` class to top level element
- Add command to "Insert Admonition" with a modal chooser
- Add command to "Replace Admonitions with HTML"

## 5.0.0

- Added [RPG Awesome Icons](http://nagoshiashumari.github.io/Rpg-Awesome/) as an option for admonition icons.
Expand Down
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": "5.0.3",
"version": "6.0.0",
"minAppVersion": "0.11.0",
"description": "Admonition block-styled content for Obsidian.md",
"author": "Jeremy Valentine",
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-admonition",
"version": "5.0.3",
"version": "6.0.0",
"description": "Admonition block-styled content for Obsidian.md",
"main": "main.js",
"scripts": {
Expand All @@ -18,8 +18,11 @@
"@rollup/plugin-commonjs": "^15.1.0",
"@rollup/plugin-node-resolve": "^9.0.0",
"@rollup/plugin-typescript": "^6.0.0",
"@types/html": "^1.0.0",
"@types/node": "^14.14.2",
"@types/object.fromentries": "^2.0.0",
"html": "^1.0.0",
"nanoid": "^3.1.23",
"object.fromentries": "^2.0.4",
"obsidian": "https://github.com/obsidianmd/obsidian-api/tarball/master",
"rollup": "^2.32.1",
Expand Down
10 changes: 6 additions & 4 deletions src/@types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ export interface ISettingsData {
syntaxHighlight: boolean;
copyButton: boolean;
autoCollapse: boolean;
defaultCollapseType: string;
defaultCollapseType: "open" | "closed";
syncLinks: boolean;
version: string;
enableMarkdownProcessor: boolean;
}

export type AdmonitionIconDefinition = {
Expand All @@ -36,16 +37,17 @@ export type AdmonitionIconName = AdmonitionIconDefinition["name"];
export type AdmonitionIconType = AdmonitionIconDefinition["type"];

export declare class ObsidianAdmonitionPlugin extends Plugin_2 {
removeAdmonition: (admonition: Admonition) => Promise<void>;
admonitions: { [admonitionType: string]: Admonition };
/* userAdmonitions: { [admonitionType: string]: Admonition };
syntaxHighlight: boolean; */
data: ISettingsData;
get admonitionArray(): Admonition[];
turnOnSyntaxHighlighting: (types?: string[]) => void;
turnOffSyntaxHighlighting: (types?: string[]) => void;
enableMarkdownProcessor: () => void;
disableMarkdownProcessor: () => void;
saveSettings: () => Promise<void>;
loadSettings: () => Promise<void>;
addAdmonition: (admonition: Admonition) => Promise<void>;
removeAdmonition: (admonition: Admonition) => Promise<void>;
onload: () => Promise<void>;
onunload: () => Promise<void>;
postprocessor: (
Expand Down
Loading

0 comments on commit 6521c0b

Please sign in to comment.