Skip to content

Commit 6521c0b

Browse files
authored
6.0.0
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"
2 parents 3d37aad + 448e71a commit 6521c0b

File tree

9 files changed

+814
-46
lines changed

9 files changed

+814
-46
lines changed

README.md

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod nulla.
3232
```
3333
````
3434

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

3737
### Titles
3838

@@ -330,6 +330,76 @@ An icon without a title will have this CSS:
330330
}
331331
```
332332

333+
## Global Commands
334+
335+
Several commands are available for the plugin by default.
336+
337+
### Collapse and Open All Admonitions In Note
338+
339+
If these two commands are triggered with an open note, all collapsible admonitions will be collapsed or open respectively.
340+
341+
### Replace Admonitions With HTML
342+
343+
Replace _all_ admonition source blocks with the rendered HTML in the note content.
344+
345+
This command will overwrite all Admonitions in the open note.
346+
347+
### Insert Admonition
348+
349+
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.
350+
351+
### Admonition-specific commands
352+
353+
Commands may be registered for each custom admonition type to insert them into an open note by clicking the `Register Commands` button.
354+
355+
See [this section](#register-and-unregister-commands) for more information.
356+
357+
## Non-code block Admonitions
358+
359+
As of version 6.0.0, there is a new setting: Enable Non-codeblock Admonitions.
360+
361+
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.
362+
363+
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:
364+
365+
```
366+
!!! ad-<type> Title goes here!
367+
368+
content
369+
370+
--- admonition
371+
```
372+
373+
This will create the appropriate admonition type, embed the content, and give it the supplied title.
374+
375+
A collapsible admonition may be created using the following syntax:
376+
377+
```
378+
??? ad-<type> Title goes here!
379+
380+
content
381+
382+
--- admonition
383+
```
384+
385+
A collapsible admonition may default to "open" by appending a +:
386+
387+
```
388+
???+ ad-<type> Title goes here!
389+
390+
content
391+
392+
--- admonition
393+
```
394+
395+
### Caveats
396+
397+
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).
398+
2. Nested admonitions are not currently supported.
399+
3. Empty titles are not currently supported.
400+
401+
If you experience any bugs using this setting, please create an issue and I will look into them.
402+
333403
## Settings
334404

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

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

415+
### Enable Non-codeblock Admonitions
416+
417+
Allow use of non-codeblock admonitions, described [here](#non-code-block-admonitions).
418+
345419
### Collapsible By Default
346420

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

383457
# Version History
384458

459+
## 6.0.0
460+
- Added ability to define admonitions without using a code block
461+
- Added `.admonition-plugin` class to top level element
462+
- Add command to "Insert Admonition" with a modal chooser
463+
- Add command to "Replace Admonitions with HTML"
464+
385465
## 5.0.0
386466

387467
- Added [RPG Awesome Icons](http://nagoshiashumari.github.io/Rpg-Awesome/) as an option for admonition icons.

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "obsidian-admonition",
33
"name": "Admonition",
4-
"version": "5.0.3",
4+
"version": "6.0.0",
55
"minAppVersion": "0.11.0",
66
"description": "Admonition block-styled content for Obsidian.md",
77
"author": "Jeremy Valentine",

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-admonition",
3-
"version": "5.0.3",
3+
"version": "6.0.0",
44
"description": "Admonition block-styled content for Obsidian.md",
55
"main": "main.js",
66
"scripts": {
@@ -18,8 +18,11 @@
1818
"@rollup/plugin-commonjs": "^15.1.0",
1919
"@rollup/plugin-node-resolve": "^9.0.0",
2020
"@rollup/plugin-typescript": "^6.0.0",
21+
"@types/html": "^1.0.0",
2122
"@types/node": "^14.14.2",
2223
"@types/object.fromentries": "^2.0.0",
24+
"html": "^1.0.0",
25+
"nanoid": "^3.1.23",
2326
"object.fromentries": "^2.0.4",
2427
"obsidian": "https://github.com/obsidianmd/obsidian-api/tarball/master",
2528
"rollup": "^2.32.1",

src/@types/index.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ export interface ISettingsData {
2222
syntaxHighlight: boolean;
2323
copyButton: boolean;
2424
autoCollapse: boolean;
25-
defaultCollapseType: string;
25+
defaultCollapseType: "open" | "closed";
2626
syncLinks: boolean;
2727
version: string;
28+
enableMarkdownProcessor: boolean;
2829
}
2930

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

3839
export declare class ObsidianAdmonitionPlugin extends Plugin_2 {
39-
removeAdmonition: (admonition: Admonition) => Promise<void>;
4040
admonitions: { [admonitionType: string]: Admonition };
41-
/* userAdmonitions: { [admonitionType: string]: Admonition };
42-
syntaxHighlight: boolean; */
4341
data: ISettingsData;
42+
get admonitionArray(): Admonition[];
4443
turnOnSyntaxHighlighting: (types?: string[]) => void;
4544
turnOffSyntaxHighlighting: (types?: string[]) => void;
45+
enableMarkdownProcessor: () => void;
46+
disableMarkdownProcessor: () => void;
4647
saveSettings: () => Promise<void>;
4748
loadSettings: () => Promise<void>;
4849
addAdmonition: (admonition: Admonition) => Promise<void>;
50+
removeAdmonition: (admonition: Admonition) => Promise<void>;
4951
onload: () => Promise<void>;
5052
onunload: () => Promise<void>;
5153
postprocessor: (

0 commit comments

Comments
 (0)