Skip to content

Commit 96445b3

Browse files
authored
Merge pull request #25 from swiftlysingh/cursor/custom-fonts-support-95e2
Add DSL node styling support
2 parents a2aa7cd + 68da6f9 commit 96445b3

4 files changed

Lines changed: 445 additions & 9 deletions

File tree

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ excalidraw-cli convert diagram.excalidraw --format svg --no-export-background
8787
| `{Label}` | Diamond | Decisions, conditionals |
8888
| `(Label)` | Ellipse | Start/End points |
8989
| `[[Label]]` | Database | Data storage |
90+
| `[Label @fillStyle:hachure @backgroundColor:#a5d8ff]` | Styled node | Add inline node style attributes |
9091
| `->` | Arrow | Connection |
9192
| `-->` | Dashed Arrow | Dashed connection |
9293
| `-> "text" ->` | Labeled Arrow | Connection with label |
@@ -99,6 +100,41 @@ excalidraw-cli convert diagram.excalidraw --format svg --no-export-background
99100
{Valid?} -> "no" -> [Show Error] -> [Enter Credentials]
100101
```
101102

103+
### Node Styling
104+
105+
Add shape-level styling directly to nodes with inline `@key:value` attributes:
106+
107+
```excalidraw
108+
(Start) -> [Enter Credentials @fillStyle:hachure @backgroundColor:#a5d8ff] -> {Valid?}
109+
{Valid?} -> "no" -> [Show Error @backgroundColor:#ffc9c9 @strokeStyle:dashed] -> [Enter Credentials]
110+
```
111+
112+
For repeated or shared nodes, define defaults with an `@node` block:
113+
114+
```excalidraw
115+
@node [Enter Credentials]
116+
fillStyle: solid
117+
backgroundColor: #a5d8ff
118+
119+
(Start) -> [Enter Credentials @fillStyle:hachure] -> {Valid?}
120+
```
121+
122+
Supported node style keys:
123+
124+
- `fillStyle`: `solid`, `hachure`, `cross-hatch`
125+
- `backgroundColor`
126+
- `strokeColor`
127+
- `strokeWidth`
128+
- `strokeStyle`: `solid`, `dashed`, `dotted`
129+
- `roughness`
130+
- `opacity`
131+
132+
Precedence rules:
133+
134+
- `@node` blocks provide defaults for matching nodes
135+
- inline node attributes override block values
136+
- repeated references to the same node merge explicit style properties with later values winning per property
137+
102138
### Directives
103139

104140
```

man/excalidraw-cli.1

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,14 @@ Ellipse node.
173173
.B [[Label]]
174174
Database node.
175175
.TP
176+
.BI "[Label @key:value ...]"
177+
Rectangle node with inline style attributes.
178+
.TP
179+
.BI "@node [Label]"
180+
Start a node-style block followed by indented
181+
.I key: value
182+
lines.
183+
.TP
176184
.B ![path]
177185
Image node using the default image size.
178186
.TP
@@ -193,6 +201,34 @@ Nodes are deduplicated by label and type.
193201
Chains such as
194202
.B [A] -> [B] -> [C]
195203
produce one edge per hop.
204+
.SS "Node styling"
205+
.P
206+
Shape nodes can define style properties inline:
207+
.P
208+
.B [Login @fillStyle:hachure @backgroundColor:#a5d8ff]
209+
.P
210+
Supported style keys are
211+
.BR fillStyle ,
212+
.BR backgroundColor ,
213+
.BR strokeColor ,
214+
.BR strokeWidth ,
215+
.BR strokeStyle ,
216+
.BR roughness ,
217+
and
218+
.BR opacity .
219+
.P
220+
Node styles can also be declared in a block:
221+
.P
222+
.RS
223+
.nf
224+
@node [Login]
225+
fillStyle: hachure
226+
backgroundColor: #a5d8ff
227+
.fi
228+
.RE
229+
.P
230+
When both forms are used, block styles provide defaults and inline attributes
231+
override them on matching nodes.
196232
.SS "Comments"
197233
.TP
198234
.B # comment
@@ -378,6 +414,9 @@ excalidraw-cli create --format json --inline '{"nodes":[{"id":"a","type":"rectan
378414
.B Create from stdin
379415
echo "[A] -> [B]" | excalidraw-cli create --stdin -o diagram.excalidraw
380416
.TP
417+
.B Create a styled node from inline DSL
418+
excalidraw-cli create --inline "(Start) -> [Login @fillStyle:hachure @backgroundColor:#a5d8ff] -> (End)" -o styled.excalidraw
419+
.TP
381420
.B Write to stdout
382421
excalidraw-cli create flowchart.dsl -o -
383422
.TP

0 commit comments

Comments
 (0)