mdat-plugin-tldraw 1.0.0
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/dist/index.d.ts +10 -0
- package/dist/index.js +3649 -0
- package/license.txt +21 -0
- package/package.json +67 -0
- package/readme.md +103 -0
package/license.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Eric Mika
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mdat-plugin-tldraw",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Mdat plugin to embed tldraw diagrams in Markdown files.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"markdown",
|
|
7
|
+
"mdat-plugin",
|
|
8
|
+
"mdat",
|
|
9
|
+
"npm-package",
|
|
10
|
+
"tldraw"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/kitschpatrol/mdat-plugin-tldraw",
|
|
13
|
+
"bugs": "https://github.com/kitschpatrol/mdat-plugin-tldraw/issues",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/kitschpatrol/mdat-plugin-tldraw.git"
|
|
17
|
+
},
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"author": {
|
|
20
|
+
"name": "Eric Mika",
|
|
21
|
+
"email": "eric@ericmika.com",
|
|
22
|
+
"url": "https://ericmika.com"
|
|
23
|
+
},
|
|
24
|
+
"type": "module",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"import": "./dist/index.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"main": "./dist/index.js",
|
|
32
|
+
"module": "./dist/index.js",
|
|
33
|
+
"files": [
|
|
34
|
+
"dist/*"
|
|
35
|
+
],
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@kitschpatrol/tldraw-cli": "^5.0.0",
|
|
38
|
+
"type-fest": "^5.2.0"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@kitschpatrol/shared-config": "^5.7.4",
|
|
42
|
+
"@types/node": "^20.19.24",
|
|
43
|
+
"bumpp": "^10.3.1",
|
|
44
|
+
"path-type": "^6.0.0",
|
|
45
|
+
"tsdown": "^0.15.12",
|
|
46
|
+
"typescript": "~5.9.3",
|
|
47
|
+
"vitest": "^4.0.6",
|
|
48
|
+
"zod": "^3.25.76"
|
|
49
|
+
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"mdat": "^1.1.0"
|
|
52
|
+
},
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">=20.19.0"
|
|
55
|
+
},
|
|
56
|
+
"publishConfig": {
|
|
57
|
+
"access": "public"
|
|
58
|
+
},
|
|
59
|
+
"scripts": {
|
|
60
|
+
"build": "tsdown --tsconfig tsconfig.build.json",
|
|
61
|
+
"clean": "git rm -f pnpm-lock.yaml ; git clean -fdX",
|
|
62
|
+
"fix": "ksc fix",
|
|
63
|
+
"lint": "ksc lint",
|
|
64
|
+
"release": "bumpp --commit 'Release: %s' && pnpm run build && NPM_AUTH_TOKEN=$(op read 'op://Personal/npm/token') && pnpm publish",
|
|
65
|
+
"test": "vitest --no-file-parallelism"
|
|
66
|
+
}
|
|
67
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
<!--+ Warning: Content inside HTML comment blocks was generated by mdat and may be overwritten. +-->
|
|
2
|
+
|
|
3
|
+
<!-- title -->
|
|
4
|
+
|
|
5
|
+
# mdat-plugin-tldraw
|
|
6
|
+
|
|
7
|
+
<!-- /title -->
|
|
8
|
+
|
|
9
|
+
<!-- badges -->
|
|
10
|
+
|
|
11
|
+
[](https://npmjs.com/package/mdat-plugin-tldraw)
|
|
12
|
+
[](https://opensource.org/licenses/MIT)
|
|
13
|
+
|
|
14
|
+
<!-- /badges -->
|
|
15
|
+
|
|
16
|
+
<!-- short-description -->
|
|
17
|
+
|
|
18
|
+
**Mdat plugin to embed tldraw diagrams in Markdown files.**
|
|
19
|
+
|
|
20
|
+
<!-- /short-description -->
|
|
21
|
+
|
|
22
|
+
## Overview
|
|
23
|
+
|
|
24
|
+
_**This is a plugin for the [mdat CLI tool](https://github.com/kitschpatrol/mdat), which is a simple Markdown templating system optimized for embedding dynamic content in repository readmes and the like.**_
|
|
25
|
+
|
|
26
|
+
This plugin makes it easy to embed [tldraw](https://www.tldraw.com) diagrams as SVG images in your Markdown files.
|
|
27
|
+
|
|
28
|
+
The plugin automatically generates both "light" and "dark" SVG variations of a tldraw sketch, and emits a `<picture>` element per [GitHub's guidelines](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#specifying-the-theme-an-image-is-shown-to) to present the correctly themed image based on the viewer's preferences.
|
|
29
|
+
|
|
30
|
+
Generated assets are intelligently hashed to aide in cache busting. For locally referenced files, the image will only be regenerated when the content in the source file changes.
|
|
31
|
+
|
|
32
|
+
The rule Accepts either a path to a local `.tldr` file, or remote tldraw URLs.
|
|
33
|
+
|
|
34
|
+
The implementation is based on [@kitschpatrol/tldraw-cli](https://github.com/kitschpatrol/tldraw-cli), which depends on Puppeteer to generate the assets, so it can be a bit slow. Referencing local files instead of remote URLs is recommended for improved performance.
|
|
35
|
+
|
|
36
|
+
## Getting started
|
|
37
|
+
|
|
38
|
+
### Dependencies
|
|
39
|
+
|
|
40
|
+
We'll assume you have [mdat](https://github.com/kitschpatrol/mdat) installed either globally or in your local project.
|
|
41
|
+
|
|
42
|
+
### Installation
|
|
43
|
+
|
|
44
|
+
Install the plugin as a development dependency:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pnpm add -D mdat-plugin-tldraw
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Register the plugin in your mdat config file, e.g. `mdat.config.ts`:
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
import type { Config } from 'mdat'
|
|
54
|
+
import tldraw from 'mdat-plugin-tldraw'
|
|
55
|
+
|
|
56
|
+
export default {
|
|
57
|
+
rules: {
|
|
58
|
+
...tldraw,
|
|
59
|
+
},
|
|
60
|
+
} satisfies Config
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Usage
|
|
64
|
+
|
|
65
|
+
Assuming you have a `sketch.tldr` file in the root of your project, you can embed it in your Markdown file this:
|
|
66
|
+
|
|
67
|
+
```markdown
|
|
68
|
+
<!-- tldraw { src: "./sketch.tldr" } -->
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Then run the `mdat` CLI command on your Markdown file to expand the rule and embed the diagram:
|
|
72
|
+
|
|
73
|
+
```markdown
|
|
74
|
+
<!-- tldraw { src: "./sketch.tldr" } -->
|
|
75
|
+
|
|
76
|
+
<picture>
|
|
77
|
+
<source media="(prefers-color-scheme: dark)" srcset="assets/sketch-63a3366c-dark.svg">
|
|
78
|
+
<source media="(prefers-color-scheme: light)" srcset="assets/sketch-63a3366c-light.svg">
|
|
79
|
+
<img alt="tldraw diagram" src="assets/sketch-63a3366c-light.svg">
|
|
80
|
+
</picture>
|
|
81
|
+
|
|
82
|
+
<!-- /tldraw -->
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Maintainers
|
|
86
|
+
|
|
87
|
+
[@kitschpatrol](https://github.com/kitschpatrol)
|
|
88
|
+
|
|
89
|
+
<!-- contributing -->
|
|
90
|
+
|
|
91
|
+
## Contributing
|
|
92
|
+
|
|
93
|
+
[Issues](https://github.com/kitschpatrol/mdat-plugin-tldraw/issues) and pull requests are welcome.
|
|
94
|
+
|
|
95
|
+
<!-- /contributing -->
|
|
96
|
+
|
|
97
|
+
<!-- license -->
|
|
98
|
+
|
|
99
|
+
## License
|
|
100
|
+
|
|
101
|
+
[MIT](license.txt) © Eric Mika
|
|
102
|
+
|
|
103
|
+
<!-- /license -->
|