Skip to content

Commit

Permalink
chore: update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
escwxyz committed Jul 16, 2024
1 parent 3c5f18d commit 9e6d2c3
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

Added default callout content class
Update readme

### Changed

Expand Down
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ The callout would be rendered as something like this:
</div>
<div class="callout-title-text">This is an error callout</div>
</div>
<div>This is the content inside callout</div>
<div class="callout-content">This is the content inside callout</div>
</blockquote>
```

Expand All @@ -83,6 +83,34 @@ blockquote[data-callout] {
blockquote[data-callout="error"] {
background-color: red;
}

[data-expanded="false"] .callout-content {
max-height: 0;
overflow: hidden;
transition: max-height 0.2s ease-out;
}

[data-expanded="true"] .callout-content {
max-height: 100px; /* or whatever height needed */
}

[data-expandable="true"] .callout-title {
cursor: pointer;
}
```

```js
const callout = document.querySelector('.callout-error');

callout.addEventListener('click', () => {
if(callout.getAttribute('data-expandable') === 'true') {
if(callout.getAttribute('data-expanded') === 'false') {
callout.setAttribute('data-expanded', 'true');
} else {
callout.setAttribute('data-expanded', 'false');
}
}
});
```

### Configuration
Expand Down Expand Up @@ -133,6 +161,8 @@ export interface Config {
iconTagName: string;
// the custom class name to be added to the title icon element
iconClass: string;
// the custom class name to be added to the content element
contentClass: string;
// predefined callouts, an object with callout's name as key, its SVG icon as value
// see https://help.obsidian.md/Editing+and+formatting/Callouts#Supported+types
// you can customize it by overriding the same callout's icon or passing new callout with customized name and icon
Expand All @@ -148,6 +178,7 @@ const defaultConfig: Config = {
titleTextTransform: (title: string) => title.trim(),
iconTagName: "div",
iconClass: "callout-title-icon",
contentClass: "callout-content",
callouts: {
note: pencilIcon,
abstract: clipboardListIcon,
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": "remark-obsidian-callout",
"version": "1.2.0",
"version": "1.3.1",
"description": "A remark plugin to parse Obsidian callouts.",
"main": "dist/index.js",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export interface Config {
*/
iconClass: string;
/**
* the custom class name to be added to the title icon element
* the custom class name to be added to the content element
* @date 7/16/2024 - 7:20:26 PM
*
* @type {string}
Expand Down

0 comments on commit 9e6d2c3

Please sign in to comment.