sketchmark 1.0.3 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +86 -38
- package/dist/index.cjs +1694 -479
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +25 -50
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1692 -480
- package/dist/index.js.map +1 -1
- package/dist/layout/index.d.ts.map +1 -1
- package/dist/parser/index.d.ts.map +1 -1
- package/dist/render.d.ts +25 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/scene/index.d.ts.map +1 -1
- package/dist/sketchmark.iife.js +1694 -479
- package/dist/ui/canvas.d.ts +129 -0
- package/dist/ui/canvas.d.ts.map +1 -0
- package/dist/ui/editor.d.ts +48 -0
- package/dist/ui/editor.d.ts.map +1 -0
- package/dist/ui/embed.d.ts +91 -0
- package/dist/ui/embed.d.ts.map +1 -0
- package/dist/ui/shared.d.ts +6 -0
- package/dist/ui/shared.d.ts.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -60,15 +60,52 @@ a --> b label="greets"
|
|
|
60
60
|
end
|
|
61
61
|
`.trim();
|
|
62
62
|
|
|
63
|
-
const instance = render({
|
|
64
|
-
container: document.getElementById('diagram'),
|
|
65
|
-
dsl,
|
|
66
|
-
renderer: 'svg',
|
|
67
|
-
svgOptions: { showTitle: true, theme: 'light', transparent: true },
|
|
68
|
-
});
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
|
|
63
|
+
const instance = render({
|
|
64
|
+
container: document.getElementById('diagram'),
|
|
65
|
+
dsl,
|
|
66
|
+
renderer: 'svg',
|
|
67
|
+
svgOptions: { showTitle: true, theme: 'light', transparent: true },
|
|
68
|
+
});
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Reusable UI Widgets
|
|
72
|
+
|
|
73
|
+
```javascript
|
|
74
|
+
import { SketchmarkCanvas, SketchmarkEditor } from 'sketchmark';
|
|
75
|
+
|
|
76
|
+
const editor = new SketchmarkEditor({
|
|
77
|
+
container: document.getElementById('editor'),
|
|
78
|
+
value: `
|
|
79
|
+
diagram
|
|
80
|
+
box app label="App"
|
|
81
|
+
box api label="API"
|
|
82
|
+
app --> api
|
|
83
|
+
end
|
|
84
|
+
`.trim(),
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const canvas = new SketchmarkCanvas({
|
|
88
|
+
container: document.getElementById('viewport'),
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
canvas.bindEditor(editor);
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
```javascript
|
|
95
|
+
import { SketchmarkEmbed } from 'sketchmark';
|
|
96
|
+
|
|
97
|
+
const embed = new SketchmarkEmbed({
|
|
98
|
+
container: document.getElementById('article-embed'),
|
|
99
|
+
dsl,
|
|
100
|
+
width: 960,
|
|
101
|
+
height: 540,
|
|
102
|
+
playStepDelay: 700,
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Use `SketchmarkCanvas` for the full playground-style surface, and `SketchmarkEmbed` for fixed-size embeds that clip overflow and follow animation targets as steps advance.
|
|
107
|
+
|
|
108
|
+
---
|
|
72
109
|
|
|
73
110
|
## Framework Setup
|
|
74
111
|
|
|
@@ -363,22 +400,34 @@ a --> b label="HTTPS" stroke="#cc0000" stroke-width=2 color="#aa0000" font-size=
|
|
|
363
400
|
|
|
364
401
|
---
|
|
365
402
|
|
|
366
|
-
## Groups
|
|
367
|
-
|
|
368
|
-
Groups visually contain one or more nodes, tables,
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
403
|
+
## Groups
|
|
404
|
+
|
|
405
|
+
Groups visually contain one or more nodes, tables, charts, markdown blocks,
|
|
406
|
+
or other groups by referencing their ids with `items=[...]`.
|
|
407
|
+
|
|
408
|
+
```
|
|
409
|
+
box a label="Node A"
|
|
410
|
+
box b label="Node B"
|
|
411
|
+
box c label="Node C"
|
|
412
|
+
|
|
413
|
+
group inner label="Inner Group" layout=row items=[c]
|
|
414
|
+
group outer label="Outer Group" layout=column items=[a,b,inner]
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
General form:
|
|
418
|
+
|
|
419
|
+
```
|
|
420
|
+
group <id> [label="..."] [layout=row|column|grid] [gap=N] [padding=N]
|
|
421
|
+
[columns=N] [align=start|center|end]
|
|
422
|
+
[justify=start|center|end|space-between|space-around]
|
|
423
|
+
[theme=...] [fill="..."] [stroke="..."] [width=N] [height=N]
|
|
424
|
+
[items=[id1,id2,...]]
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
- Groups are always declared at the top level.
|
|
428
|
+
- `items` order is the visual child order.
|
|
429
|
+
- Nested groups are created by referencing another group id from `items=[...]`.
|
|
430
|
+
- All authored nodes, groups, tables, charts, and markdown blocks must have explicit ids.
|
|
382
431
|
|
|
383
432
|
### Group Properties
|
|
384
433
|
|
|
@@ -400,14 +449,13 @@ group <id> [label="..."] [layout=row|column|grid] [gap=N] [padding=N]
|
|
|
400
449
|
|
|
401
450
|
#### `bare` keyword
|
|
402
451
|
|
|
403
|
-
`bare` is an alias for a group with no visible border or fill:
|
|
404
|
-
|
|
405
|
-
```
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
```
|
|
452
|
+
`bare` is an alias for a group with no visible border or fill:
|
|
453
|
+
|
|
454
|
+
```
|
|
455
|
+
box a label="Floating A"
|
|
456
|
+
box b label="Floating B"
|
|
457
|
+
bare myContainer layout=row items=[a,b]
|
|
458
|
+
```
|
|
411
459
|
|
|
412
460
|
---
|
|
413
461
|
|
|
@@ -534,9 +582,9 @@ theme muted fill="#f5f5f5" stroke="#999999" color="#444444"
|
|
|
534
582
|
|
|
535
583
|
box client label="Client" theme=primary
|
|
536
584
|
box server label="Server" theme=warning
|
|
537
|
-
cylinder db label="DB" theme=success
|
|
538
|
-
group services label="Services" theme=muted
|
|
539
|
-
```
|
|
585
|
+
cylinder db label="DB" theme=success
|
|
586
|
+
group services label="Services" theme=muted items=[client,server,db]
|
|
587
|
+
```
|
|
540
588
|
|
|
541
589
|
---
|
|
542
590
|
|
|
@@ -1062,8 +1110,8 @@ exportHTML(instance.svg, dslSource, { filename: 'diagram.html' });
|
|
|
1062
1110
|
| `<-->` | Edge | `a <--> b` |
|
|
1063
1111
|
| `--` | Edge | `a -- b` |
|
|
1064
1112
|
| `---` | Edge | `a --- b` |
|
|
1065
|
-
| `group` | Group | `group myGroup label="Services" layout=column
|
|
1066
|
-
| `bare` | Group | `bare myWrap
|
|
1113
|
+
| `group` | Group | `group myGroup label="Services" layout=column items=[api,db]` |
|
|
1114
|
+
| `bare` | Group | `bare myWrap layout=row items=[a,b]` |
|
|
1067
1115
|
| `table` | Table | `table myTable label="Users" { header Name Age }` |
|
|
1068
1116
|
| `bar-chart` | Chart | `bar-chart sales label="Sales" data [...]` |
|
|
1069
1117
|
| `line-chart` | Chart | `line-chart trend data [...]` |
|