Skip to content

Commit e7c54a2

Browse files
authored
Merge pull request #27 from GRA0007/feat/custom-palettes
Add custom palette support
2 parents 36f23b4 + 7562be6 commit e7c54a2

16 files changed

Lines changed: 4404 additions & 216 deletions

.changes/add-palettes.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"obsidian-css-inlay-colors": minor:feat
3+
---
4+
5+
Adds support for custom palettes that let you use standard color charts like RAL (e.g. `(RAL 1004)` or `(aci 91)`)

.changes/fix-preview-border.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"obsidian-css-inlay-colors": patch:fix
3+
---
4+
5+
Ensure borders between the preview and text are hidden with certain themes in the live preview mode

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,8 @@ main.js
77
# Exclude sourcemaps
88
*.map
99

10-
# obsidian
10+
# Obsidian
1111
data.json
12+
13+
# Dev
14+
palette-colors.json

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ To use, just put any [valid CSS color syntax](https://developer.mozilla.org/en-U
1010

1111
<img src="example.jpg" alt="Example of the extension running for all CSS color formats" width="200">
1212

13+
## Features
14+
1315
### Color Picker
1416

1517
Enable the color picker setting to change a color using a color picker in live preview mode. Note that the color picker does not support opacity, and will only let you select from sRGB colors. It will attempt to preserve the existing format you have written, as well as any existing opacity.
@@ -24,6 +26,33 @@ Surround a color with square brackets (\`[\#663399]\`) to hide the color name an
2426

2527
There's also an option in the plugin settings to hide all color names globally.
2628

29+
### Custom Palettes
30+
31+
This plugin supports custom color palettes which you can use by enabling the setting and creating a [CSS snippet](https://help.obsidian.md/snippets) file that targets the palette names you want to support.
32+
33+
Enabling the setting exposes classes for every inline code block surrounded by parentheses, replacing all spaces with hyphens, and converting to lowercase. For example, \`(RAL 170 50 10)\` exposes the class `.ral-170-50-10`. If that class gets a `color` set, it will show a color inlay.
34+
35+
Note, the plugin detects classes that target `.css-color-inlay` only, see the example below.
36+
37+
```css
38+
.css-color-inlay.my-cool-color { color: #663399; }
39+
/* Or, use CSS nesting */
40+
.css-color-inlay {
41+
&.my-hot-color { color: orangered; }
42+
}
43+
/* Now `(my cool color)` and `(my hot color)` will have inlays */
44+
```
45+
46+
#### Predefined Palettes
47+
48+
There are 6 [predefined color palettes](./palettes.css) you can download using the button in the settings, and it includes the following:
49+
50+
- AutoCAD Color Index
51+
- Australian Color Standard (AS 2700)
52+
- British Standard Colors (BS 381, BS 4800)
53+
- Federal Standard (FS 595C, ANA)
54+
- RAL Colors (Classic, Design, Effect, Plastics)
55+
2756
### Custom CSS
2857

2958
Customize the inlays by targeting the `.css-color-inlay` class. For example, you can make them circular with the following snippet:

biome.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,8 @@
2525
"quoteStyle": "single",
2626
"semicolons": "asNeeded"
2727
}
28+
},
29+
"files": {
30+
"includes": ["**", "!palettes.css"]
2831
}
2932
}

package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "obsidian-css-inlay-colors",
33
"version": "1.3.1",
4-
"packageManager": "pnpm@10.17.1+sha512.17c560fca4867ae9473a3899ad84a88334914f379be46d455cbf92e5cf4b39d34985d452d2583baf19967fa76cb5c17bc9e245529d0b98745721aa7200ecaf7a",
4+
"packageManager": "pnpm@10.18.3+sha512.bbd16e6d7286fd7e01f6b3c0b3c932cda2965c06a908328f74663f10a9aea51f1129eea615134bf992831b009eabe167ecb7008b597f40ff9bc75946aadfb08d",
55
"description": "Show inline color hints for CSS colors",
66
"main": "main.js",
77
"scripts": {
@@ -20,7 +20,8 @@
2020
"inlay",
2121
"picker",
2222
"hex",
23-
"rgb"
23+
"rgb",
24+
"palette"
2425
],
2526
"author": "Benji Grant",
2627
"license": "MIT",
@@ -29,20 +30,20 @@
2930
"url": "https://github.com/GRA0007/obsidian-css-inlay-colors.git"
3031
},
3132
"devDependencies": {
32-
"@biomejs/biome": "^2.2.4",
33+
"@biomejs/biome": "^2.2.6",
3334
"@types/culori": "^4.0.1",
34-
"@types/node": "^24.5.2",
35+
"@types/node": "^24.8.1",
3536
"builtin-modules": "5.0.0",
3637
"covector": "^0.12.4",
37-
"esbuild": "0.25.10",
38+
"esbuild": "0.25.11",
3839
"obsidian": "latest",
3940
"tslib": "2.8.1",
40-
"typescript": "5.9.2"
41+
"typescript": "5.9.3"
4142
},
4243
"dependencies": {
4344
"@codemirror/language": "^6.11.3",
4445
"@codemirror/state": "^6.5.2",
45-
"@codemirror/view": "^6.38.3",
46+
"@codemirror/view": "^6.38.6",
4647
"culori": "^4.0.2"
4748
}
4849
}

0 commit comments

Comments
 (0)