Compare commits

...

17 commits

Author SHA1 Message Date
@gapmiss
e6e1f76e8f chore: release 0.1.11 2026-06-25 16:38:40 -05:00
@gapmiss
3755d19417 fix: render inline callout labels containing square brackets in Live Preview
The Live Preview decorator used `[^\]]*` for the label, which stops at the
first `]`. A multi-part label like `[!!mail|test [with brackets]|var(...)]`
broke as soon as it hit the `]` after "brackets", so the closing ]` no longer
matched and the callout stayed as raw code. Reading mode was unaffected
because its post-processor checks startsWith/endsWith. Switch the class to
`[^`]+` so it matches up to the bounding backtick, consistent with the
post-processor and cursor-detection regexes.

Co-authored-by: Thierry VUILLEMIN <6804067+vuillemint@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-25 16:37:38 -05:00
@gapmiss
858a209cbe fix: sync versions.json with manifest.json minAppVersion and bump esbuild
versions.json was out of sync — releases 0.1.5–0.1.10 incorrectly listed
minAppVersion as 0.15.0 instead of 1.4.10. Also updates release.mjs to
read minAppVersion from manifest.json rather than hardcoding it, and bumps
esbuild from 0.25.4 to 0.28.1.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-14 12:07:54 -05:00
@gapmiss
ef1fca869e docs: remove duplicate Installation section from README.md 2026-06-06 15:46:56 -05:00
@gapmiss
5da6a34253 fix: update package-lock.json for removed packages 2026-06-06 15:31:31 -05:00
@gapmiss
ae2caf86b6 chore: release 0.1.10 2026-06-06 14:42:33 -05:00
@gapmiss
3cb8a6d45e fix: remove unused variables in editor view
Remove dead code (_currentLine, startOfLine, endOfLine) flagged by
community plugin scanner. Per-match selection checking already handles
cursor overlap.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-06-06 14:42:24 -05:00
@gapmiss
d20986d90a chore: release 0.1.9 2026-06-06 14:32:07 -05:00
@gapmiss
a03e81ed06 fix: enable strict mode and fix TypeScript errors
Update tsconfig.json for TypeScript 5.9+ compatibility:
- Remove deprecated baseUrl, use moduleResolution "bundler"
- Enable strict mode to match IDE settings
- Scope include to src/**/*.ts

Fix strict mode violations across codebase.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-06-06 14:31:46 -05:00
@gapmiss
dcde16861f docs: update README.md 2026-06-02 17:14:27 -05:00
@gapmiss
d208ad379a chore: release 0.1.8 2026-05-31 14:12:43 -05:00
@gapmiss
2501bea1bc docs: add CONTRIBUTING guide 2026-05-31 14:12:33 -05:00
@gapmiss
e063d0145a chore: release 0.1.7 2026-05-30 17:55:01 -05:00
@gapmiss
b0835b9889 feat: add custom font CSS variable
Added --inline-callout-font-family variable (default: inherit).
Configurable via Style Settings plugin.

Closes #6

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-30 17:46:14 -05:00
@gapmiss
750716057c feat: add no-icon button to modals
Both new and modify modals now show "None" text when no-icon is selected
and include a circle-off button to quickly set icon to none.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-30 17:40:19 -05:00
@gapmiss
224a035795 feat: add no-icon support with none/blank
Use `none` or `blank` as the icon name to render a callout without an icon.
Icons ending with `-none` also work. The icon space is not reserved.

Closes #4

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-30 17:30:34 -05:00
@gapmiss
cf52f94f29 feat: add hex color support
Support hex colors (#RGB, #RRGGBB) in addition to RGB values and CSS variables.
Color picker in modals now preserves hex format instead of converting to RGB.

Closes #2

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-30 17:20:54 -05:00
18 changed files with 356 additions and 255 deletions

1
.gitignore vendored
View file

@ -21,5 +21,4 @@ data.json
# Exclude macOS Finder (System Explorer) View States
.DS_Store
.hotreload
.claude

24
CONTRIBUTING.md Normal file
View file

@ -0,0 +1,24 @@
# Contributing
Thanks for your interest in contributing!
## Bug reports
Open an issue with steps to reproduce and expected vs actual behavior.
## Pull requests
1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Run `npm run build` and `npx eslint .` to verify
5. Test in Obsidian
6. Submit a PR with a clear description
## Development
```bash
npm install
npm run dev # Watch mode
npm run build # Production build
```

View file

@ -4,16 +4,30 @@
A plugin for displaying inline "callouts" in [Obsidian.md](https://github.com/obsidianmd); a successor to the [Badges](https://github.com/gapmiss/badges) plugin by the same author. Key differences: simpler syntax, access to all Lucide icons in Obsidian, modal interfaces for icon suggestions, new inline callout and modify inline callout.
- [Demo](#demo)
- [Features](#features)
- [Usage](#usage)
- [Caveats](#caveats)
- [Installation](#installation)
- [CSS styles](#css)
- [Style Settings plugin](#style-settings-plugin)
- [Development](#development)
- [Credits](#credits)
- [Notes](#notes)
## Installation
[Install from community.obsidian.md](https://community.obsidian.md/plugins/inline-callouts)
From Obsidian's settings or preferences:
1. Community Plugins > Browse
2. Search for "Inline Callouts"
Manually:
1. download the latest [release](https://github.com/gapmiss/inline-callouts/releases/latest) archive
2. uncompress the downloaded archive
3. move the `inline-callouts` folder to `/path/to/vault/.obsidian/plugins/`
4. Settings > Community plugins > reload **Installed plugins**
5. enable plugin
or:
1. download `main.js`, `manifest.json` & `styles.css` from the latest [release](https://github.com/gapmiss/inline-callouts/releases/latest)
2. create a new folder `/path/to/vault/.obsidian/plugins/inline-callouts`
3. move all 3 files to `/path/to/vault/.obsidian/plugins/inline-callouts`
4. Settings > Community plugins > reload **Installed plugins**
5. enable plugin
## Demo
@ -94,11 +108,11 @@ A plugin for displaying inline "callouts" in [Obsidian.md](https://github.com/ob
`[!!ICON|LABEL|COLOR]`
```
| Syntax | Details |
| ----------------- | ------------------------------ |
| `ICON` | Name of the Lucide icon |
| `LABEL`(optional) | Callout label/title text |
| `COLOR`(optional) | RGB values or Obsidian CSS var |
| Syntax | Details |
| ----------------- | -------------------------------------------------- |
| `ICON` | Lucide icon name, or `none`/`blank` for no icon |
| `LABEL`(optional) | Callout label/title text |
| `COLOR`(optional) | Hex, RGB values, or Obsidian CSS var |
> [!IMPORTANT]
@ -116,31 +130,6 @@ A plugin for displaying inline "callouts" in [Obsidian.md](https://github.com/ob
| `[!!info\|Lorem\|var(--color-blue-rgb)]` |
```
## Installation
[Find at Obsidian.md/plugins](https://obsidian.md/plugins?search=inline-callouts)
From Obsidian's settings:
1. Community Plugins > Browse
2. Search for "Inline Callouts"
Via BRAT (Beta Reviewer's Auto-update Tool):
1. Ensure [BRAT](https://github.com/TfTHacker/obsidian42-brat) is installed
2. Trigger the command Obsidian42 - BRAT: Add a beta plugin for testing
3. Enter this repository, gapmiss/inline-callouts
4. Enable the "Inline Callouts" plugin in the community plugin list
Manually:
1. download `main.js`, `manifest.json` & `styles.css` from the latest [release](https://github.com/gapmiss/inline-callouts/releases/)
2. create a new folder `/path/to/vault/.obsidian/plugins/inline-callouts`
3. move all 3 files to `/path/to/vault/.obsidian/plugins/inline-callouts`
4. Settings > Community plugins > reload **Installed plugins**
5. enable plugin
## CSS
Custom `CSS` styles can be applied via CSS snippets. All colors and styles can be over-written just the same.
@ -151,6 +140,7 @@ See [CSS snippets - Obsidian Help](https://help.obsidian.md/Extending+Obsidian/C
```css
body {
--inline-callout-font-family: inherit;
--inline-callout-font-size: .85em;
--inline-callout-font-weight: 400;
--inline-callout-border-radius: 4px;

View file

@ -1,7 +1,7 @@
{
"id": "inline-callouts",
"name": "Inline Callouts",
"version": "0.1.6",
"version": "0.1.11",
"minAppVersion": "1.4.10",
"description": "Add inline callouts/badges to notes.",
"author": "@gapmiss",

244
package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "inline-callouts",
"version": "0.1.5",
"version": "0.1.10",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "inline-callouts",
"version": "0.1.5",
"version": "0.1.10",
"license": "MIT",
"dependencies": {
"@codemirror/state": "^6.0.0",
@ -15,8 +15,7 @@
"devDependencies": {
"@types/node": "^16.11.6",
"@typescript-eslint/parser": "^8.0.0",
"builtin-modules": "3.3.0",
"esbuild": "^0.25.4",
"esbuild": "^0.28.1",
"eslint": "^9.0.0",
"eslint-plugin-obsidianmd": "^0.3.0",
"obsidian": "latest",
@ -47,9 +46,9 @@
}
},
"node_modules/@esbuild/aix-ppc64": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.4.tgz",
"integrity": "sha512-1VCICWypeQKhVbE9oW/sJaAmjLxhVqacdkvPLEjwlttjfwENRSClS8EjBz0KzRyFSCPDIkuXW34Je/vk7zdB7Q==",
"version": "0.28.1",
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.1.tgz",
"integrity": "sha512-Svl7tq8k/08+p6CXPpRjQ1fKX+1odH/BQbb48fV6fj3CWHhsoIOoY87w1oHXm0qEpkIK3ZfVgp0hed3XBXzXMQ==",
"cpu": [
"ppc64"
],
@ -64,9 +63,9 @@
}
},
"node_modules/@esbuild/android-arm": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.4.tgz",
"integrity": "sha512-QNdQEps7DfFwE3hXiU4BZeOV68HHzYwGd0Nthhd3uCkkEKK7/R6MTgM0P7H7FAs5pU/DIWsviMmEGxEoxIZ+ZQ==",
"version": "0.28.1",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.28.1.tgz",
"integrity": "sha512-0k2F129Xdio1TdJfzJ8sy1Q47vUD2NnwdhiAf7drUN1EBTfPf4hsFCtmMgu/6m8JSzsBrlmVjudMBQqOfG8usQ==",
"cpu": [
"arm"
],
@ -81,9 +80,9 @@
}
},
"node_modules/@esbuild/android-arm64": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.4.tgz",
"integrity": "sha512-bBy69pgfhMGtCnwpC/x5QhfxAz/cBgQ9enbtwjf6V9lnPI/hMyT9iWpR1arm0l3kttTr4L0KSLpKmLp/ilKS9A==",
"version": "0.28.1",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.28.1.tgz",
"integrity": "sha512-34EGEbCIAgosYz6goLcopX6Mo7NyGv9tfwEM2/7Ce2VcVRk568iSvniGWcUXIy7wEDR1wzolcxcriFVrWYcwBg==",
"cpu": [
"arm64"
],
@ -98,9 +97,9 @@
}
},
"node_modules/@esbuild/android-x64": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.4.tgz",
"integrity": "sha512-TVhdVtQIFuVpIIR282btcGC2oGQoSfZfmBdTip2anCaVYcqWlZXGcdcKIUklfX2wj0JklNYgz39OBqh2cqXvcQ==",
"version": "0.28.1",
"resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.28.1.tgz",
"integrity": "sha512-dbwY7ltSMDWsRatcRpCnES4F+im88OCUgGZjy52shC7GqHRE/cYlxNbB4Z4UpJswpcc4Qxd2oE/ufM0p61IKng==",
"cpu": [
"x64"
],
@ -115,9 +114,9 @@
}
},
"node_modules/@esbuild/darwin-arm64": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.4.tgz",
"integrity": "sha512-Y1giCfM4nlHDWEfSckMzeWNdQS31BQGs9/rouw6Ub91tkK79aIMTH3q9xHvzH8d0wDru5Ci0kWB8b3up/nl16g==",
"version": "0.28.1",
"resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.28.1.tgz",
"integrity": "sha512-TZbWkQY7kvTAXbXUT7uVACR5cMHsDiSz9z7ZKAX/RTq/WJEk3QyRr0wZpNhBDX+/0CtdqUIJlOiodQcta6tY3Q==",
"cpu": [
"arm64"
],
@ -132,9 +131,9 @@
}
},
"node_modules/@esbuild/darwin-x64": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.4.tgz",
"integrity": "sha512-CJsry8ZGM5VFVeyUYB3cdKpd/H69PYez4eJh1W/t38vzutdjEjtP7hB6eLKBoOdxcAlCtEYHzQ/PJ/oU9I4u0A==",
"version": "0.28.1",
"resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.28.1.tgz",
"integrity": "sha512-zfdzgK9ACBNZLI/CyHTOx81SyNbM6YXn7rxSgX97VjyiPl9W1i4Ka4fgKECEoFCKGpvBj5qArWIGgQjOwkgskQ==",
"cpu": [
"x64"
],
@ -149,9 +148,9 @@
}
},
"node_modules/@esbuild/freebsd-arm64": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.4.tgz",
"integrity": "sha512-yYq+39NlTRzU2XmoPW4l5Ifpl9fqSk0nAJYM/V/WUGPEFfek1epLHJIkTQM6bBs1swApjO5nWgvr843g6TjxuQ==",
"version": "0.28.1",
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.28.1.tgz",
"integrity": "sha512-wG2EA8ENdEI0qhkSZMjfqrdY+ziCYCPMmtZjjIwOmXFjmyzEHn+UUxk5of+SYsjtfs3VpnlC7QLzSI5hY/rOAw==",
"cpu": [
"arm64"
],
@ -166,9 +165,9 @@
}
},
"node_modules/@esbuild/freebsd-x64": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.4.tgz",
"integrity": "sha512-0FgvOJ6UUMflsHSPLzdfDnnBBVoCDtBTVyn/MrWloUNvq/5SFmh13l3dvgRPkDihRxb77Y17MbqbCAa2strMQQ==",
"version": "0.28.1",
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.28.1.tgz",
"integrity": "sha512-i7dZ9vQgnvSCzi/rYCXNgtF/U+eKZNJBzu3eTQbRgHnM7tNSizLOkRFAl3qzVc/Op/u5YkHHa4pf/3DOYHthLQ==",
"cpu": [
"x64"
],
@ -183,9 +182,9 @@
}
},
"node_modules/@esbuild/linux-arm": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.4.tgz",
"integrity": "sha512-kro4c0P85GMfFYqW4TWOpvmF8rFShbWGnrLqlzp4X1TNWjRY3JMYUfDCtOxPKOIY8B0WC8HN51hGP4I4hz4AaQ==",
"version": "0.28.1",
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.28.1.tgz",
"integrity": "sha512-qVXBOHQS+d5Y722GwJzJUtOLlX7km3CraOaGormF1pDtPd2C/l1SHRPgjLunLGe51Sh5YYWKMFDyV4SxgMQYTQ==",
"cpu": [
"arm"
],
@ -200,9 +199,9 @@
}
},
"node_modules/@esbuild/linux-arm64": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.4.tgz",
"integrity": "sha512-+89UsQTfXdmjIvZS6nUnOOLoXnkUTB9hR5QAeLrQdzOSWZvNSAXAtcRDHWtqAUtAmv7ZM1WPOOeSxDzzzMogiQ==",
"version": "0.28.1",
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.28.1.tgz",
"integrity": "sha512-yHs+0uc8+nvEAfAfxrWQKK5peSNzBc4PegcMO0EJ2hT71uA7vB8Ihg2e77R2P7SG5uYjPbHlLLmve4LLLRCf0g==",
"cpu": [
"arm64"
],
@ -217,9 +216,9 @@
}
},
"node_modules/@esbuild/linux-ia32": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.4.tgz",
"integrity": "sha512-yTEjoapy8UP3rv8dB0ip3AfMpRbyhSN3+hY8mo/i4QXFeDxmiYbEKp3ZRjBKcOP862Ua4b1PDfwlvbuwY7hIGQ==",
"version": "0.28.1",
"resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.28.1.tgz",
"integrity": "sha512-d1z4ZuP0ajrfz/FhGT4vv278rX8KnPPJx8i5+AtK7TYbx9Le9F1hyzurZpkEyjkGa9dUGhQow4C1NmeGvqxN2w==",
"cpu": [
"ia32"
],
@ -234,9 +233,9 @@
}
},
"node_modules/@esbuild/linux-loong64": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.4.tgz",
"integrity": "sha512-NeqqYkrcGzFwi6CGRGNMOjWGGSYOpqwCjS9fvaUlX5s3zwOtn1qwg1s2iE2svBe4Q/YOG1q6875lcAoQK/F4VA==",
"version": "0.28.1",
"resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.28.1.tgz",
"integrity": "sha512-M5sRjUVZrkm1OAPR3dlOYzNmN+loZKGVi1VUQGrwuqLcbR6qeAz+famMhjASeH3YVKvZz+zT1jlh/keC3Rj/lg==",
"cpu": [
"loong64"
],
@ -251,9 +250,9 @@
}
},
"node_modules/@esbuild/linux-mips64el": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.4.tgz",
"integrity": "sha512-IcvTlF9dtLrfL/M8WgNI/qJYBENP3ekgsHbYUIzEzq5XJzzVEV/fXY9WFPfEEXmu3ck2qJP8LG/p3Q8f7Zc2Xg==",
"version": "0.28.1",
"resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.28.1.tgz",
"integrity": "sha512-mRObBZeHh2OxcBFPWE/FjylkRgZdYuiTR3vaTozquCGOH14iP9oN4x4Ge81CoIDYQrXmIxpFumJBu5MtZpnQJQ==",
"cpu": [
"mips64el"
],
@ -268,9 +267,9 @@
}
},
"node_modules/@esbuild/linux-ppc64": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.4.tgz",
"integrity": "sha512-HOy0aLTJTVtoTeGZh4HSXaO6M95qu4k5lJcH4gxv56iaycfz1S8GO/5Jh6X4Y1YiI0h7cRyLi+HixMR+88swag==",
"version": "0.28.1",
"resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.28.1.tgz",
"integrity": "sha512-slScBsMAb3GFDcdrCgLwZtPYRoH2H/youv10QiZyRjmsP48fznoveWytSgCI/R0ZcUgpc0ZhIUEx6LHts8yrfQ==",
"cpu": [
"ppc64"
],
@ -285,9 +284,9 @@
}
},
"node_modules/@esbuild/linux-riscv64": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.4.tgz",
"integrity": "sha512-i8JUDAufpz9jOzo4yIShCTcXzS07vEgWzyX3NH2G7LEFVgrLEhjwL3ajFE4fZI3I4ZgiM7JH3GQ7ReObROvSUA==",
"version": "0.28.1",
"resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.28.1.tgz",
"integrity": "sha512-kw0owk1o0GFETUJyW0jc0G4Yzs0BHZn0JDZ8JRT088vjJYX777BAs1fDGxAC+q831qOs2DTC96mNsG2opdfyyQ==",
"cpu": [
"riscv64"
],
@ -302,9 +301,9 @@
}
},
"node_modules/@esbuild/linux-s390x": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.4.tgz",
"integrity": "sha512-jFnu+6UbLlzIjPQpWCNh5QtrcNfMLjgIavnwPQAfoGx4q17ocOU9MsQ2QVvFxwQoWpZT8DvTLooTvmOQXkO51g==",
"version": "0.28.1",
"resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.28.1.tgz",
"integrity": "sha512-/lAIjX8aYFRByhh6L5rYtPEDRqa9de/4V/juOXcta5frjvzXO4/sqEtyytse0g3zZFuWu5cDN0MkLz2qRDD2Ag==",
"cpu": [
"s390x"
],
@ -319,9 +318,9 @@
}
},
"node_modules/@esbuild/linux-x64": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.4.tgz",
"integrity": "sha512-6e0cvXwzOnVWJHq+mskP8DNSrKBr1bULBvnFLpc1KY+d+irZSgZ02TGse5FsafKS5jg2e4pbvK6TPXaF/A6+CA==",
"version": "0.28.1",
"resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.28.1.tgz",
"integrity": "sha512-u/anNYF2mmVOEDwLtnQ1wOr3EZ9sTNGLWrsYGYwHWzGA3Si84IOkHXlbWTD1NB+9/1lcnweYKO54uhxZydNzfA==",
"cpu": [
"x64"
],
@ -336,9 +335,9 @@
}
},
"node_modules/@esbuild/netbsd-arm64": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.4.tgz",
"integrity": "sha512-vUnkBYxZW4hL/ie91hSqaSNjulOnYXE1VSLusnvHg2u3jewJBz3YzB9+oCw8DABeVqZGg94t9tyZFoHma8gWZQ==",
"version": "0.28.1",
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.28.1.tgz",
"integrity": "sha512-oks0DYbLwWMmaakTsCb+zL4E+aHRVLom9IJZOAthMQEPiQmydXHkziYEsGYRx0uNV/IjEKGAV941JzH02pflqw==",
"cpu": [
"arm64"
],
@ -353,9 +352,9 @@
}
},
"node_modules/@esbuild/netbsd-x64": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.4.tgz",
"integrity": "sha512-XAg8pIQn5CzhOB8odIcAm42QsOfa98SBeKUdo4xa8OvX8LbMZqEtgeWE9P/Wxt7MlG2QqvjGths+nq48TrUiKw==",
"version": "0.28.1",
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.28.1.tgz",
"integrity": "sha512-aeL6lAnN89Hz43Mlh1G8ARasbuoYvSITDEx0tHh5b7jJnHcssqgjy9Yx430GDpmCa6OyrKoS0aNRjKundRizGg==",
"cpu": [
"x64"
],
@ -370,9 +369,9 @@
}
},
"node_modules/@esbuild/openbsd-arm64": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.4.tgz",
"integrity": "sha512-Ct2WcFEANlFDtp1nVAXSNBPDxyU+j7+tId//iHXU2f/lN5AmO4zLyhDcpR5Cz1r08mVxzt3Jpyt4PmXQ1O6+7A==",
"version": "0.28.1",
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.28.1.tgz",
"integrity": "sha512-MEFJe5C3R8pwXdZ5Y21oo6m7ePiS0d9pWucn99O/wvyJZChoIQKrQDxKrGeW8F5+T0okTHesAmDeiHDTIq0V/Q==",
"cpu": [
"arm64"
],
@ -387,9 +386,9 @@
}
},
"node_modules/@esbuild/openbsd-x64": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.4.tgz",
"integrity": "sha512-xAGGhyOQ9Otm1Xu8NT1ifGLnA6M3sJxZ6ixylb+vIUVzvvd6GOALpwQrYrtlPouMqd/vSbgehz6HaVk4+7Afhw==",
"version": "0.28.1",
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.28.1.tgz",
"integrity": "sha512-i/ZLIOafE0Z8cI/XANJAixoJL/uRAoS2xOA3rb0xN+KK0K177cMAsQYkzHtBrtMXAKuAc7HGgcWiZ/sRC1Nxgw==",
"cpu": [
"x64"
],
@ -403,10 +402,27 @@
"node": ">=18"
}
},
"node_modules/@esbuild/openharmony-arm64": {
"version": "0.28.1",
"resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.28.1.tgz",
"integrity": "sha512-ge+Z7EXFNt2BO1oAMsVpiQ8EwndV9i1xXerAeTIK7AtPs3bKFXQM7nlRxDSIUIMeueR1CNXxqztLzdNeReKBJg==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"openharmony"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/sunos-x64": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.4.tgz",
"integrity": "sha512-Mw+tzy4pp6wZEK0+Lwr76pWLjrtjmJyUB23tHKqEDP74R3q95luY/bXqXZeYl4NYlvwOqoRKlInQialgCKy67Q==",
"version": "0.28.1",
"resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.28.1.tgz",
"integrity": "sha512-BEjgtECkL3vY+SaSQ6nzVfiALUeFxpawyp8Jmf5PtYhf1Ug40N1h/hxlhts+f1FvSvarEigdxS3BlSMI2PJLcQ==",
"cpu": [
"x64"
],
@ -421,9 +437,9 @@
}
},
"node_modules/@esbuild/win32-arm64": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.4.tgz",
"integrity": "sha512-AVUP428VQTSddguz9dO9ngb+E5aScyg7nOeJDrF1HPYu555gmza3bDGMPhmVXL8svDSoqPCsCPjb265yG/kLKQ==",
"version": "0.28.1",
"resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.28.1.tgz",
"integrity": "sha512-lCv9eK/H6ZJWbE7bh2nw54CZ9M2nupBxJcTsdk/QQnWkdSjKGuxmmH8/GWrlT1eMmZfn4dGcCjRte397WqfQXA==",
"cpu": [
"arm64"
],
@ -438,9 +454,9 @@
}
},
"node_modules/@esbuild/win32-ia32": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.4.tgz",
"integrity": "sha512-i1sW+1i+oWvQzSgfRcxxG2k4I9n3O9NRqy8U+uugaT2Dy7kLO9Y7wI72haOahxceMX8hZAzgGou1FhndRldxRg==",
"version": "0.28.1",
"resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.28.1.tgz",
"integrity": "sha512-zvb/mB2bSCoJOpoCBgYKKpX6YM6mJBlBUVUtVj41DlZJVEB6/0CKlRYxP5wWl1C1ILiCoAU5wZZ4q1P3qeS6Eg==",
"cpu": [
"ia32"
],
@ -455,9 +471,9 @@
}
},
"node_modules/@esbuild/win32-x64": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.4.tgz",
"integrity": "sha512-nOT2vZNw6hJ+z43oP1SPea/G/6AbN6X+bGNhNuq8NtRHy4wsMhw765IKLNmnjek7GvjWBYQ8Q5VBoYTFg9y1UQ==",
"version": "0.28.1",
"resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.28.1.tgz",
"integrity": "sha512-bm4Mowrv+GXMlpWX++EcXw/iLyd1o3+bJkC2DkWXYVvgZCqD/bSj9ctZeAMC3cIxgjRVR2Dufaiu4YPxr5gW1A==",
"cpu": [
"x64"
],
@ -1366,19 +1382,6 @@
"concat-map": "0.0.1"
}
},
"node_modules/builtin-modules": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.3.0.tgz",
"integrity": "sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=6"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/call-bind": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.9.tgz",
@ -1849,9 +1852,9 @@
}
},
"node_modules/esbuild": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.4.tgz",
"integrity": "sha512-8pgjLUcUjcgDg+2Q4NYXnPbo/vncAY4UmyaCm0jZevERqCHZIaWwdJHkf8XQtu4AxSKCdvrUbT0XUr1IdZzI8Q==",
"version": "0.28.1",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.1.tgz",
"integrity": "sha512-HrJrvZv5ayxBzPfwphOoNzkzOIIlifzk0KJrGK2c8R4+LKpMtpYLQeUdjnwjWv/LZlkH2laZk+4w78pi99D4Vw==",
"dev": true,
"hasInstallScript": true,
"license": "MIT",
@ -1862,31 +1865,32 @@
"node": ">=18"
},
"optionalDependencies": {
"@esbuild/aix-ppc64": "0.25.4",
"@esbuild/android-arm": "0.25.4",
"@esbuild/android-arm64": "0.25.4",
"@esbuild/android-x64": "0.25.4",
"@esbuild/darwin-arm64": "0.25.4",
"@esbuild/darwin-x64": "0.25.4",
"@esbuild/freebsd-arm64": "0.25.4",
"@esbuild/freebsd-x64": "0.25.4",
"@esbuild/linux-arm": "0.25.4",
"@esbuild/linux-arm64": "0.25.4",
"@esbuild/linux-ia32": "0.25.4",
"@esbuild/linux-loong64": "0.25.4",
"@esbuild/linux-mips64el": "0.25.4",
"@esbuild/linux-ppc64": "0.25.4",
"@esbuild/linux-riscv64": "0.25.4",
"@esbuild/linux-s390x": "0.25.4",
"@esbuild/linux-x64": "0.25.4",
"@esbuild/netbsd-arm64": "0.25.4",
"@esbuild/netbsd-x64": "0.25.4",
"@esbuild/openbsd-arm64": "0.25.4",
"@esbuild/openbsd-x64": "0.25.4",
"@esbuild/sunos-x64": "0.25.4",
"@esbuild/win32-arm64": "0.25.4",
"@esbuild/win32-ia32": "0.25.4",
"@esbuild/win32-x64": "0.25.4"
"@esbuild/aix-ppc64": "0.28.1",
"@esbuild/android-arm": "0.28.1",
"@esbuild/android-arm64": "0.28.1",
"@esbuild/android-x64": "0.28.1",
"@esbuild/darwin-arm64": "0.28.1",
"@esbuild/darwin-x64": "0.28.1",
"@esbuild/freebsd-arm64": "0.28.1",
"@esbuild/freebsd-x64": "0.28.1",
"@esbuild/linux-arm": "0.28.1",
"@esbuild/linux-arm64": "0.28.1",
"@esbuild/linux-ia32": "0.28.1",
"@esbuild/linux-loong64": "0.28.1",
"@esbuild/linux-mips64el": "0.28.1",
"@esbuild/linux-ppc64": "0.28.1",
"@esbuild/linux-riscv64": "0.28.1",
"@esbuild/linux-s390x": "0.28.1",
"@esbuild/linux-x64": "0.28.1",
"@esbuild/netbsd-arm64": "0.28.1",
"@esbuild/netbsd-x64": "0.28.1",
"@esbuild/openbsd-arm64": "0.28.1",
"@esbuild/openbsd-x64": "0.28.1",
"@esbuild/openharmony-arm64": "0.28.1",
"@esbuild/sunos-x64": "0.28.1",
"@esbuild/win32-arm64": "0.28.1",
"@esbuild/win32-ia32": "0.28.1",
"@esbuild/win32-x64": "0.28.1"
}
},
"node_modules/escape-string-regexp": {

View file

@ -1,6 +1,6 @@
{
"name": "inline-callouts",
"version": "0.1.6",
"version": "0.1.11",
"description": "Inline Callouts: Add inline callouts/badges to notes",
"main": "main.js",
"scripts": {
@ -17,7 +17,7 @@
"devDependencies": {
"@types/node": "^16.11.6",
"@typescript-eslint/parser": "^8.0.0",
"esbuild": "^0.25.4",
"esbuild": "^0.28.1",
"eslint": "^9.0.0",
"eslint-plugin-obsidianmd": "^0.3.0",
"obsidian": "latest",
@ -28,5 +28,8 @@
"dependencies": {
"@codemirror/state": "^6.0.0",
"@codemirror/view": "^6.0.0"
},
"allowScripts": {
"esbuild@0.28.1": true
}
}

View file

@ -23,7 +23,7 @@ const VERSION_TYPES = {
// Default settings
const DEFAULT_VERSION_TYPE = VERSION_TYPES.PATCH;
const RELEASE_FILES = ['main.js', 'manifest.json', 'styles.css'];
const MIN_APP_VERSION = "0.15.0"
const MIN_APP_VERSION = JSON.parse(readFileSync(path.resolve(process.cwd(), 'manifest.json'), 'utf8')).minAppVersion;
// Store original versions for rollback if needed
let originalPackageVersion = '';

View file

@ -3,6 +3,43 @@ import {
setIcon
} from 'obsidian';
function parseColorToRgb(color: string): string | null {
const trimmed = color.trim();
// Hex color (3, 4, 6, or 8 digit)
if (trimmed.startsWith('#')) {
let hex = trimmed.slice(1);
// Expand 3-digit hex to 6-digit
if (hex.length === 3) {
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
}
// Expand 4-digit hex (with alpha) to 8-digit
if (hex.length === 4) {
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2] + hex[3] + hex[3];
}
// Parse 6-digit or 8-digit hex
if (hex.length === 6 || hex.length === 8) {
const r = parseInt(hex.slice(0, 2), 16);
const g = parseInt(hex.slice(2, 4), 16);
const b = parseInt(hex.slice(4, 6), 16);
if (!isNaN(r) && !isNaN(g) && !isNaN(b)) {
return `${r}, ${g}, ${b}`;
}
}
return null;
}
// Already RGB format (e.g., "255, 0, 0")
return trimmed;
}
function isNoIcon(icon: string): boolean {
return icon === 'none' || icon === 'blank' || icon.endsWith('-none');
}
export class InlineCallout {
newEl: HTMLSpanElement;
@ -33,11 +70,12 @@ export class InlineCallout {
let calloutColorStyle: string;
// no content, return <code>
const noIcon = calloutIcon ? isNoIcon(calloutIcon) : false;
if (
!content.length
|| parts.length === 0
|| !calloutIcon
|| (getIconIds().indexOf('lucide-' + calloutIcon) == -1 && getIconIds().indexOf(calloutIcon) == -1) // 404, no icon found
|| (!noIcon && getIconIds().indexOf('lucide-' + calloutIcon) == -1 && getIconIds().indexOf(calloutIcon) == -1) // 404, no icon found
) {
const codeEl = createEl("code");
codeEl.setText(text);
@ -52,26 +90,35 @@ export class InlineCallout {
// icon only
if (parts.length === 1) {
this.iconEl.setAttr("aria-label", calloutIcon);
setIcon(this.iconEl, calloutIcon);
this.newEl.appendChild(this.iconEl);
if (!noIcon) {
this.iconEl.setAttr("aria-label", calloutIcon);
setIcon(this.iconEl, calloutIcon);
this.newEl.appendChild(this.iconEl);
}
return this.newEl;
}
// icon and color only
if (!calloutLabel && calloutColor) {
calloutColorStyle = "color: rgba(" + calloutColor + ", 1);"
this.iconEl.setAttr("style", calloutColorStyle);
this.iconEl.setAttr("aria-label", calloutIcon);
setIcon(this.iconEl, calloutIcon);
this.newEl.appendChild(this.iconEl);
if (!noIcon) {
const rgb = parseColorToRgb(calloutColor);
if (rgb) {
calloutColorStyle = "color: rgba(" + rgb + ", 1);"
this.iconEl.setAttr("style", calloutColorStyle);
}
this.iconEl.setAttr("aria-label", calloutIcon);
setIcon(this.iconEl, calloutIcon);
this.newEl.appendChild(this.iconEl);
}
return this.newEl;
}
// icon
this.iconEl.setAttr("aria-label", calloutIcon);
setIcon(this.iconEl, calloutIcon);
this.newEl.appendChild(this.iconEl);
if (!noIcon) {
this.iconEl.setAttr("aria-label", calloutIcon);
setIcon(this.iconEl, calloutIcon);
this.newEl.appendChild(this.iconEl);
}
// label?
if (calloutLabel) {
this.labelEl.setText(calloutLabel);
@ -79,8 +126,11 @@ export class InlineCallout {
}
// color?
if (calloutLabel && calloutColor) {
calloutColorStyle = "color: rgba(" + calloutColor + ", 1); background-color: rgba(" + calloutColor + ", var(--inline-callout-bg-transparency));"
this.newEl.setAttr("style", calloutColorStyle)
const rgb = parseColorToRgb(calloutColor);
if (rgb) {
calloutColorStyle = "color: rgba(" + rgb + ", 1); background-color: rgba(" + rgb + ", var(--inline-callout-bg-transparency));"
this.newEl.setAttr("style", calloutColorStyle)
}
}
return this.newEl;
}

View file

@ -4,8 +4,7 @@ import {
MarkdownPostProcessorContext,
Editor,
MarkdownView,
Notice,
Menu
Notice
} from 'obsidian';
import {
InlineCalloutsSettings,
@ -33,7 +32,7 @@ interface ContextData {
export default class InlineCalloutsPlugin extends Plugin {
settings: InlineCalloutsSettings;
settings!: InlineCalloutsSettings;
public postprocessor: MarkdownPostProcessor = (el: HTMLElement, _ctx: MarkdownPostProcessorContext) => {
const blockToReplace = el.querySelectorAll('code')
@ -82,14 +81,17 @@ export default class InlineCalloutsPlugin extends Plugin {
id: "modify",
name: "Modify inline callout",
icon: "form-input",
editorCheckCallback: (checking, editor, view: MarkdownView) => {
editorCheckCallback: (checking, editor, ctx) => {
if (!this.settings.enableEditing) {
return false;
}
const res = this.checkContextType(editor, view);
if (!(ctx instanceof MarkdownView)) {
return false;
}
const res = this.checkContextType(editor, ctx);
if (res) {
if (!checking) {
this.modifyInlineCallout(editor, view);
this.modifyInlineCallout(editor, ctx);
}
return true;
}
@ -108,21 +110,22 @@ export default class InlineCalloutsPlugin extends Plugin {
});
this.registerEvent(
this.app.workspace.on("editor-menu", (menu: Menu, editor: Editor, view: MarkdownView) => {
this.app.workspace.on("editor-menu", (menu, editor, info) => {
if (this.settings.enableEditing) {
const res = this.checkContextType(editor, view);
if (!(info instanceof MarkdownView)) {
return;
}
const res = this.checkContextType(editor, info);
if (res) {
menu.addItem(item => {
item
.setTitle('Modify inline callout')
.setIcon('form-input')
.onClick(async () => {
this.modifyInlineCallout(editor, view);
.onClick(() => {
this.modifyInlineCallout(editor, info);
});
})
return true;
});
}
return false;
}
})
);

View file

@ -17,10 +17,10 @@ interface ContextData {
export class ModifyInlineCalloutModal extends Modal {
public calloutIcon: string;
public calloutIcon: string = 'info';
public calloutColor: string | undefined;
public calloutLabel: string | undefined;
previewEl: HTMLDivElement;
previewEl!: HTMLDivElement;
activeDoc: Document = window.activeDocument ?? window.document;
constructor(
@ -63,18 +63,23 @@ export class ModifyInlineCalloutModal extends Modal {
this.calloutColor = this.calloutColor ? this.calloutColor : (parts[2] ? parts[2].trim() : undefined);
}
const isNoIcon = this.calloutIcon === 'none' || this.calloutIcon === 'blank' || this.calloutIcon?.endsWith('-none');
new Setting(contentEl)
.setName('Icon')
.setDesc('To select an icon, click the button. Default: info')
.addButton((cb) => {
cb
.setIcon(this.calloutIcon ? this.calloutIcon : "lucide-info")
.setTooltip("Select icon")
if (isNoIcon) {
cb.setButtonText('None');
} else {
cb.setIcon(this.calloutIcon ? this.calloutIcon : "lucide-info");
}
cb.setTooltip(isNoIcon ? "No icon" : "Select icon")
.onClick((e) => {
e.preventDefault();
const modal = new IconSuggest(this.plugin, (icon) => {
this.calloutIcon = icon;
this.buildPreview();
this.display(false, false, true);
});
modal.open();
});
@ -88,12 +93,22 @@ export class ModifyInlineCalloutModal extends Modal {
const modal = new IconSuggest(this.plugin, (icon) => {
this.calloutIcon = icon;
this.buildPreview();
this.display(false, false, true);
});
modal.open();
break;
}
}
});
})
.addExtraButton((cb) => {
cb.setIcon('circle-off')
.setTooltip('No icon')
.onClick(() => {
this.calloutIcon = 'none';
this.buildPreview();
this.display(false, false, true);
});
});
new Setting(contentEl)
@ -111,18 +126,18 @@ export class ModifyInlineCalloutModal extends Modal {
});
});
const hexToRgb = (hex: string) => {
const r = parseInt(hex.slice(1, 3), 16);
const g = parseInt(hex.slice(3, 5), 16);
const b = parseInt(hex.slice(5, 7), 16);
return `${r}, ${g}, ${b}`;
};
function rgbToHex(r: number, g: number, b: number) {
return '#' + ((1 << 24) + (r << 16) + (g << 8) + b)
.toString(16)
.slice(1)
.toUpperCase();
function colorToHex(color: string | undefined): string {
if (!color) return '#000000';
if (color.startsWith('#')) return color;
// Convert RGB string to hex
const parts = color.split(',').map(s => parseInt(s.trim(), 10));
if (parts.length >= 3 && parts.every(n => !isNaN(n))) {
return '#' + ((1 << 24) + (parts[0] << 16) + (parts[1] << 8) + parts[2])
.toString(16)
.slice(1)
.toUpperCase();
}
return '#000000';
}
new Setting(contentEl)
@ -155,18 +170,9 @@ export class ModifyInlineCalloutModal extends Modal {
})
})
.addColorPicker((cb) => {
let r = 0;
let g = 0;
let b = 0;
if (this.calloutColor) {
const colorArr = this.calloutColor.split(",");
r = Number(colorArr[0] ?? 0);
g = Number(colorArr[1] ?? 0);
b = Number(colorArr[2] ?? 0);
}
cb.setValue(rgbToHex(r, g, b))
cb.setValue(colorToHex(this.calloutColor))
.onChange((value) => {
this.calloutColor = hexToRgb(value);
this.calloutColor = value;
const dropdown = this.activeDoc.querySelector<HTMLSelectElement>(".modify-inline-callout-modal .inline-callouts-color-dropdown .dropdown");
if (dropdown) dropdown.value = '';
this.buildPreview();

View file

@ -13,7 +13,7 @@ export class NewInlineCalloutModal extends Modal {
public calloutIcon: string = 'lucide-info';
public calloutColor: string | undefined;
public calloutLabel: string | undefined;
previewEl: HTMLDivElement;
previewEl!: HTMLDivElement;
activeDoc: Document = window.activeDocument ?? window.document;
constructor(
@ -38,18 +38,23 @@ export class NewInlineCalloutModal extends Modal {
this.titleEl.setText("New inline callout");
const isNoIcon = this.calloutIcon === 'none' || this.calloutIcon === 'blank' || this.calloutIcon?.endsWith('-none');
new Setting(contentEl)
.setName('Icon')
.setDesc('To select an icon, click the button. Default: info')
.addButton((cb) => {
cb
.setIcon(this.calloutIcon)
.setTooltip("Select icon")
if (isNoIcon) {
cb.setButtonText('None');
} else {
cb.setIcon(this.calloutIcon);
}
cb.setTooltip(isNoIcon ? "No icon" : "Select icon")
.onClick((e) => {
e.preventDefault();
const modal = new IconSuggest(this.plugin, (icon) => {
this.calloutIcon = icon;
this.buildPreview();
this.display(false);
});
modal.open();
});
@ -63,12 +68,22 @@ export class NewInlineCalloutModal extends Modal {
const modal = new IconSuggest(this.plugin, (icon) => {
this.calloutIcon = icon;
this.buildPreview();
this.display(false);
});
modal.open();
break;
}
}
});
})
.addExtraButton((cb) => {
cb.setIcon('circle-off')
.setTooltip('No icon')
.onClick(() => {
this.calloutIcon = 'none';
this.buildPreview();
this.display(false);
});
});
new Setting(contentEl)
@ -82,13 +97,6 @@ export class NewInlineCalloutModal extends Modal {
});
});
const hexToRgb = (hex: string) => {
const r = parseInt(hex.slice(1, 3), 16);
const g = parseInt(hex.slice(3, 5), 16);
const b = parseInt(hex.slice(5, 7), 16);
return `${r}, ${g}, ${b}`;
};
new Setting(contentEl)
.setName('Color')
.setDesc('Pick a color using the dropdown or color picker. Default: Obsidian\'s base color')
@ -119,9 +127,9 @@ export class NewInlineCalloutModal extends Modal {
})
})
.addColorPicker((cb) => {
cb.setValue(this.calloutColor ?? '#000000')
cb.setValue(this.calloutColor?.startsWith('#') ? this.calloutColor : '#000000')
.onChange((value) => {
this.calloutColor = hexToRgb(value);
this.calloutColor = value;
const dropdown = this.activeDoc.querySelector<HTMLSelectElement>(".new-inline-callout-modal .inline-callouts-color-dropdown .dropdown");
if (dropdown) dropdown.value = '';
this.buildPreview();

View file

@ -9,7 +9,7 @@ import type InlineCalloutsPlugin from "../main";
export class SearchInlineCalloutsModal extends Modal {
public calloutIcon: string;
public calloutIcon: string = '';
constructor(
private plugin: InlineCalloutsPlugin,

View file

@ -3,7 +3,7 @@ import {
PluginSettingTab,
Setting
} from 'obsidian';
import InlineCalloutsPlugin from 'src/main';
import InlineCalloutsPlugin from '../main';
export interface InlineCalloutsSettings {
enableSuggester: boolean;

View file

@ -14,6 +14,7 @@ export class InputIconSuggest extends AbstractInputSuggest<string> {
) {
super(app, inputEl);
this.textInputEl = inputEl;
}
getSuggestions(inputStr: string): string[] {

View file

@ -5,7 +5,7 @@ import { ViewPlugin, WidgetType, EditorView, ViewUpdate, Decoration, DecorationS
import { RangeSetBuilder } from "@codemirror/state";
import { InlineCallout } from '../callout/builder';
const REGEXP = /(`\[!!([^\]]*)\]`)/gm;
const REGEXP = /(`\[!!([^`]+)\]`)/gm;
export const viewPlugin = ViewPlugin.fromClass(class {
decorations: DecorationSet;
@ -37,18 +37,7 @@ export const viewPlugin = ViewPlugin.fromClass(class {
for (let n of lines) {
const line = view.state.doc.line(n);
const startOfLine = line.from;
const endOfLine = line.to;
let _currentLine = false;
currentSelections.forEach((r) => {
if (r.to >= startOfLine && r.from <= endOfLine) {
_currentLine = true;
return;
}
});
let matches = Array.from(line.text.matchAll(REGEXP))
const matches = Array.from(line.text.matchAll(REGEXP))
for (const match of matches) {
let add = true;
const from = match.index != undefined ? match.index + line.from : -1

View file

@ -1,4 +1,5 @@
body {
--inline-callout-font-family: inherit;
--inline-callout-font-size: .85em;
--inline-callout-font-weight: 400;
--inline-callout-border-radius: 4px;
@ -45,6 +46,7 @@ body {
}
.inline-callout-label {
font-family: var(--inline-callout-font-family);
font-size: var(--inline-callout-font-size);
margin-top: var(--inline-callout-label-margin-top);
margin-right: var(--inline-callout-label-margin-right);
@ -58,6 +60,19 @@ body {
width: calc(var(--dialog-width) / 1.5);
}
/* No-icon callouts: hide icon and adjust label spacing */
[data-inline-callout="none"] .inline-callout-icon,
[data-inline-callout="blank"] .inline-callout-icon,
[data-inline-callout$="-none"] .inline-callout-icon {
display: none;
}
[data-inline-callout="none"] .inline-callout-label,
[data-inline-callout="blank"] .inline-callout-label,
[data-inline-callout$="-none"] .inline-callout-label {
margin-left: var(--inline-callout-label-margin-right);
}
/* @settings
name: Inline Callouts
id: inline-callouts
@ -144,6 +159,11 @@ settings:
type: heading
level: 4
collapsed: true
-
id: inline-callout-font-family
title: Font family
type: variable-text
default: inherit
-
id: inline-callout-font-size
title: Font size

View file

@ -1,17 +1,16 @@
{
"compilerOptions": {
"baseUrl": ".",
"inlineSourceMap": true,
"inlineSources": true,
"module": "ESNext",
"target": "ES6",
"allowJs": true,
"noImplicitAny": true,
"moduleResolution": "node",
"strict": true,
"moduleResolution": "bundler",
"importHelpers": true,
"isolatedModules": true,
"allowSyntheticDefaultImports": true,
"strictNullChecks": true,
"strictNullChecks": true,
"lib": [
"DOM",
"ES5",
@ -20,6 +19,6 @@
]
},
"include": [
"**/*.ts"
"src/**/*.ts"
]
}

View file

@ -4,6 +4,11 @@
"0.1.2": "0.15.0",
"0.1.3": "0.15.0",
"0.1.4": "0.15.0",
"0.1.5": "0.15.0",
"0.1.6": "0.15.0"
"0.1.5": "1.4.10",
"0.1.6": "1.4.10",
"0.1.7": "1.4.10",
"0.1.8": "1.4.10",
"0.1.9": "1.4.10",
"0.1.10": "1.4.10",
"0.1.11": "1.4.10"
}