Skip to content

Commit 9e6d2c3

Browse files
committed
chore: update readme
1 parent 3c5f18d commit 9e6d2c3

File tree

4 files changed

+35
-4
lines changed

4 files changed

+35
-4
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10-
Added default callout content class
10+
Update readme
1111

1212
### Changed
1313

README.md

+32-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ The callout would be rendered as something like this:
6868
</div>
6969
<div class="callout-title-text">This is an error callout</div>
7070
</div>
71-
<div>This is the content inside callout</div>
71+
<div class="callout-content">This is the content inside callout</div>
7272
</blockquote>
7373
```
7474

@@ -83,6 +83,34 @@ blockquote[data-callout] {
8383
blockquote[data-callout="error"] {
8484
background-color: red;
8585
}
86+
87+
[data-expanded="false"] .callout-content {
88+
max-height: 0;
89+
overflow: hidden;
90+
transition: max-height 0.2s ease-out;
91+
}
92+
93+
[data-expanded="true"] .callout-content {
94+
max-height: 100px; /* or whatever height needed */
95+
}
96+
97+
[data-expandable="true"] .callout-title {
98+
cursor: pointer;
99+
}
100+
```
101+
102+
```js
103+
const callout = document.querySelector('.callout-error');
104+
105+
callout.addEventListener('click', () => {
106+
if(callout.getAttribute('data-expandable') === 'true') {
107+
if(callout.getAttribute('data-expanded') === 'false') {
108+
callout.setAttribute('data-expanded', 'true');
109+
} else {
110+
callout.setAttribute('data-expanded', 'false');
111+
}
112+
}
113+
});
86114
```
87115

88116
### Configuration
@@ -133,6 +161,8 @@ export interface Config {
133161
iconTagName: string;
134162
// the custom class name to be added to the title icon element
135163
iconClass: string;
164+
// the custom class name to be added to the content element
165+
contentClass: string;
136166
// predefined callouts, an object with callout's name as key, its SVG icon as value
137167
// see https://help.obsidian.md/Editing+and+formatting/Callouts#Supported+types
138168
// you can customize it by overriding the same callout's icon or passing new callout with customized name and icon
@@ -148,6 +178,7 @@ const defaultConfig: Config = {
148178
titleTextTransform: (title: string) => title.trim(),
149179
iconTagName: "div",
150180
iconClass: "callout-title-icon",
181+
contentClass: "callout-content",
151182
callouts: {
152183
note: pencilIcon,
153184
abstract: clipboardListIcon,

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "remark-obsidian-callout",
3-
"version": "1.2.0",
3+
"version": "1.3.1",
44
"description": "A remark plugin to parse Obsidian callouts.",
55
"main": "dist/index.js",
66
"type": "module",

src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export interface Config {
9898
*/
9999
iconClass: string;
100100
/**
101-
* the custom class name to be added to the title icon element
101+
* the custom class name to be added to the content element
102102
* @date 7/16/2024 - 7:20:26 PM
103103
*
104104
* @type {string}

0 commit comments

Comments
 (0)