@kitschpatrol/tldraw-cli 4.1.1 → 4.2.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/bin/cli.js +161 -136
- package/dist/.DS_Store +0 -0
- package/dist/lib/TldrawController.d.ts +25 -0
- package/dist/lib/index.js +149 -116
- package/dist/lib/inline/download-image.d.ts +7 -0
- package/dist/lib/inline/download-tldr.d.ts +7 -0
- package/dist/lib/inline/get-image-blob.d.ts +13 -0
- package/dist/lib/inline/get-image.d.ts +13 -0
- package/dist/lib/inline/get-tldr.d.ts +7 -0
- package/dist/lib/inline/set-tldr.d.ts +7 -0
- package/dist/lib/inline/upload-tldr.d.ts +7 -0
- package/dist/lib/tldraw-controller.d.ts +4 -10
- package/dist/tldraw/assets/index-BsbCikiv.js +320 -0
- package/dist/tldraw/assets/index-CtzsHuLd.css +1 -0
- package/dist/tldraw/icons/icon/checkbox-empty.svg +1 -1
- package/dist/tldraw/index.html +2 -2
- package/dist/tldraw/translations/ar.json +156 -156
- package/dist/tldraw/translations/ca.json +156 -156
- package/dist/tldraw/translations/cs.json +211 -211
- package/dist/tldraw/translations/da.json +94 -94
- package/dist/tldraw/translations/de.json +169 -169
- package/dist/tldraw/translations/es.json +160 -160
- package/dist/tldraw/translations/fa.json +202 -202
- package/dist/tldraw/translations/fi.json +172 -172
- package/dist/tldraw/translations/fr.json +156 -156
- package/dist/tldraw/translations/gl.json +208 -208
- package/dist/tldraw/translations/hi-in.json +152 -152
- package/dist/tldraw/translations/hr.json +358 -0
- package/dist/tldraw/translations/hu.json +220 -217
- package/dist/tldraw/translations/it.json +189 -189
- package/dist/tldraw/translations/ja.json +210 -210
- package/dist/tldraw/translations/ko-kr.json +217 -214
- package/dist/tldraw/translations/languages.json +8 -0
- package/dist/tldraw/translations/main.json +14 -0
- package/dist/tldraw/translations/ne.json +156 -156
- package/dist/tldraw/translations/ro.json +210 -210
- package/dist/tldraw/translations/ru.json +206 -206
- package/dist/tldraw/translations/sl.json +358 -0
- package/dist/tldraw/translations/th.json +156 -156
- package/dist/tldraw/translations/tr.json +214 -214
- package/dist/tldraw/translations/uk.json +206 -206
- package/dist/tldraw/translations/vi.json +156 -156
- package/dist/tldraw/translations/zh-cn.json +212 -212
- package/dist/tldraw/translations/zh-tw.json +176 -176
- package/package.json +20 -17
- package/readme.md +36 -27
- package/dist/tldraw/assets/index-C93mJRxX.js +0 -315
- package/dist/tldraw/assets/index-DWCRF5Ys.css +0 -1
package/readme.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!--+ Warning: Content
|
|
1
|
+
<!--+ Warning: Content inside HTML comment blocks was generated by mdat and may be overwritten. +-->
|
|
2
2
|
|
|
3
3
|
<!-- header -->
|
|
4
4
|
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://npmjs.com/package/@kitschpatrol/tldraw-cli)
|
|
8
8
|
[](https://opensource.org/licenses/MIT)
|
|
9
9
|
|
|
10
|
-
**A
|
|
10
|
+
**A CLI tool for exporting tldraw sketch URLs and local .tldr files to SVG or PNG images.**
|
|
11
11
|
|
|
12
12
|
<!-- /header -->
|
|
13
13
|
|
|
@@ -17,12 +17,13 @@
|
|
|
17
17
|
|
|
18
18
|
- [Overview](#overview)
|
|
19
19
|
- [Installation](#installation)
|
|
20
|
-
- [
|
|
21
|
-
- [
|
|
22
|
-
- [API
|
|
20
|
+
- [Usage](#usage)
|
|
21
|
+
- [CLI](#cli)
|
|
22
|
+
- [API](#api)
|
|
23
23
|
- [Background](#background)
|
|
24
24
|
- [Implementation notes](#implementation-notes)
|
|
25
25
|
- [The future](#the-future)
|
|
26
|
+
- [Maintainers](#maintainers)
|
|
26
27
|
- [Contributing](#contributing)
|
|
27
28
|
- [License](#license)
|
|
28
29
|
|
|
@@ -30,7 +31,7 @@
|
|
|
30
31
|
|
|
31
32
|
## Overview
|
|
32
33
|
|
|
33
|
-
A CLI app to automate conversion and export of [tldraw](https://tldraw.dev) URLs and `.tldr` files into SVG or PNG image formats.
|
|
34
|
+
A CLI app to automate conversion and export of [tldraw](https://tldraw.dev) URLs and `.tldr` files into SVG or PNG image formats, exposing a number of options along the way. It also provides commands for opening tldraw files in either local or remote instances of the tldraw editor website.
|
|
34
35
|
|
|
35
36
|
This could be useful in the context of a content publishing pipeline where you want to use a `.tldr` file (perhaps under version control) as the "source of truth" for assets to be embedded elsewhere, and you don't want to manage the export of that diagram manually.
|
|
36
37
|
|
|
@@ -56,7 +57,9 @@ npm install --save-dev @kitschpatrol/tldraw-cli
|
|
|
56
57
|
npm install --global @kitschpatrol/tldraw-cli
|
|
57
58
|
```
|
|
58
59
|
|
|
59
|
-
##
|
|
60
|
+
## Usage
|
|
61
|
+
|
|
62
|
+
### CLI
|
|
60
63
|
|
|
61
64
|
<!-- cli-help -->
|
|
62
65
|
|
|
@@ -72,10 +75,10 @@ Usage:
|
|
|
72
75
|
tldraw-cli <command>
|
|
73
76
|
```
|
|
74
77
|
|
|
75
|
-
| Command | Argument | Description
|
|
76
|
-
| -------- | ------------------- |
|
|
77
|
-
| `export` | `<files-or-urls..>` | Export a local tldraw ".tldr" file or a tldraw\.com URL to an svg, png, json, or tldr file. Prints the absolute path(s) to the exported image(s) to stdout.
|
|
78
|
-
| `open` | `[files-or-urls..]` | Open a tldraw `.tldr` file or tldraw\.com URL your default browser
|
|
78
|
+
| Command | Argument | Description |
|
|
79
|
+
| -------- | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
80
|
+
| `export` | `<files-or-urls..>` | Export a local tldraw ".tldr" file or a tldraw\.com URL to an svg, png, json, or tldr file. Prints the absolute path(s) to the exported image(s) to stdout. |
|
|
81
|
+
| `open` | `[files-or-urls..]` | Open a tldraw `.tldr` file or tldraw\.com URL in your default browser with either the official tldraw\.com site or a locally-hosted instance of the editor. Call `open` without an argument to open a blank sketch. Sketches opened via URL with the `--local` flag will be temporarily copied to the local system, and will not be kept in sync with tldraw\.com. This process does not exit until the browser is closed. |
|
|
79
82
|
|
|
80
83
|
| Option | Alias | Description | Type |
|
|
81
84
|
| ----------- | ----- | ------------------- | --------- |
|
|
@@ -114,7 +117,7 @@ tldraw-cli export <files-or-urls..>
|
|
|
114
117
|
|
|
115
118
|
#### Subcommand: `tldraw-cli open`
|
|
116
119
|
|
|
117
|
-
Open a tldraw `.tldr` file or tldraw\.com URL your default browser
|
|
120
|
+
Open a tldraw `.tldr` file or tldraw\.com URL in your default browser with either the official tldraw\.com site or a locally-hosted instance of the editor. Call `open` without an argument to open a blank sketch. Sketches opened via URL with the `--local` flag will be temporarily copied to the local system, and will not be kept in sync with tldraw\.com. This process does not exit until the browser is closed.
|
|
118
121
|
|
|
119
122
|
Usage:
|
|
120
123
|
|
|
@@ -135,9 +138,9 @@ tldraw-cli open [files-or-urls..]
|
|
|
135
138
|
|
|
136
139
|
<!-- /cli-help -->
|
|
137
140
|
|
|
138
|
-
|
|
141
|
+
#### Examples
|
|
139
142
|
|
|
140
|
-
|
|
143
|
+
##### Basic `.tldr` file image export
|
|
141
144
|
|
|
142
145
|
To export the file `your-drawing.tldr` to an SVG named `your-drawing.svg` in the current working directory, run the following command. Note that the default output format is SVG, and the default export location is the current working directory.
|
|
143
146
|
|
|
@@ -147,7 +150,7 @@ tldraw-cli export your-drawing.tldr
|
|
|
147
150
|
|
|
148
151
|
The file will retain its original name, e.g. `your-drawing.svg`
|
|
149
152
|
|
|
150
|
-
|
|
153
|
+
##### Basic tldraw\.com image download
|
|
151
154
|
|
|
152
155
|
```sh
|
|
153
156
|
tldraw-cli export https://www.tldraw.com/s/v2_c_JsxJk8dag6QsrqExukis4
|
|
@@ -157,7 +160,7 @@ The tldraw\.com URL's id (e.g. `v2_c_JsxJk8dag6QsrqExukis4`) will be used for th
|
|
|
157
160
|
|
|
158
161
|
This is approximately equivalent to clicking the tldraw\.com "☰ → Edit → Export As → SVG" menu item.
|
|
159
162
|
|
|
160
|
-
|
|
163
|
+
##### Export a remote tldraw\.com image to a local .tldr file
|
|
161
164
|
|
|
162
165
|
```sh
|
|
163
166
|
tldraw-cli export https://www.tldraw.com/s/v2_c_JsxJk8dag6QsrqExukis4 --format tldr
|
|
@@ -167,7 +170,7 @@ This is approximately equivalent to clicking the tldraw\.com "☰ → File → S
|
|
|
167
170
|
|
|
168
171
|
Note that using `--format tldr` with a _file path_ instead of a _URL_ will still send the file through the pipeline, but it's effectively a no-op. (Except perhaps in rare edge cases where tldraw performs a file format version migration).
|
|
169
172
|
|
|
170
|
-
|
|
173
|
+
##### Export to a specific image / file format
|
|
171
174
|
|
|
172
175
|
```sh
|
|
173
176
|
tldraw-cli export your-drawing.tldr --format png
|
|
@@ -175,7 +178,7 @@ tldraw-cli export your-drawing.tldr --format png
|
|
|
175
178
|
|
|
176
179
|
This is approximately equivalent to clicking the tldraw\.com "☰ → Edit → Export As → PNG" menu item.
|
|
177
180
|
|
|
178
|
-
|
|
181
|
+
##### Export with a transparent background
|
|
179
182
|
|
|
180
183
|
```sh
|
|
181
184
|
tldraw-cli export your-drawing.tldr --transparent --format png
|
|
@@ -183,7 +186,7 @@ tldraw-cli export your-drawing.tldr --transparent --format png
|
|
|
183
186
|
|
|
184
187
|
This is approximately equivalent to checking the tldraw\.com "☰ → Edit → Export As → ☐ Transparent" menu item.
|
|
185
188
|
|
|
186
|
-
|
|
189
|
+
##### Export to a specific destination
|
|
187
190
|
|
|
188
191
|
```sh
|
|
189
192
|
tldraw-cli export your-drawing.tldr --output ~/Desktop
|
|
@@ -191,7 +194,7 @@ tldraw-cli export your-drawing.tldr --output ~/Desktop
|
|
|
191
194
|
|
|
192
195
|
Exports to `~/Desktop/your-drawing.svg`
|
|
193
196
|
|
|
194
|
-
|
|
197
|
+
##### Export to a specific destination and filename
|
|
195
198
|
|
|
196
199
|
```sh
|
|
197
200
|
tldraw-cli export your-drawing.tldr --output ~/Desktop --name not-your-drawing
|
|
@@ -199,7 +202,7 @@ tldraw-cli export your-drawing.tldr --output ~/Desktop --name not-your-drawing
|
|
|
199
202
|
|
|
200
203
|
Exports to `~/Desktop/not-your-drawing.svg`
|
|
201
204
|
|
|
202
|
-
|
|
205
|
+
##### Export all frames from a tldraw\.com URL
|
|
203
206
|
|
|
204
207
|
```sh
|
|
205
208
|
tldraw-cli export https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw --frames
|
|
@@ -215,19 +218,19 @@ The frame name will be slugified.
|
|
|
215
218
|
|
|
216
219
|
It's possible in tldraw to give multiple frames in a single sketch the same name. In these cases, the frame ID is used in addition to the name to ensure unique output file names.
|
|
217
220
|
|
|
218
|
-
|
|
221
|
+
##### Export a specific frame from a tldraw\.com URL
|
|
219
222
|
|
|
220
223
|
```sh
|
|
221
224
|
tldraw-cli export https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw --frames "Frame 3"
|
|
222
225
|
```
|
|
223
226
|
|
|
224
|
-
|
|
227
|
+
##### Export multiple frames from a tldraw\.com URL
|
|
225
228
|
|
|
226
229
|
```sh
|
|
227
230
|
tldraw-cli export https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw --frames "Frame 1" "Frame 3"
|
|
228
231
|
```
|
|
229
232
|
|
|
230
|
-
|
|
233
|
+
##### Export to JSON
|
|
231
234
|
|
|
232
235
|
```sh
|
|
233
236
|
tldraw-cli export https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw --format "json"
|
|
@@ -237,13 +240,13 @@ The `.tldr` file format is also JSON under the covers, but the `--format json` f
|
|
|
237
240
|
|
|
238
241
|
I'm not completely clear on the use-case for this format, but since tldr.com supports it, so too shall `tldraw-cli`.
|
|
239
242
|
|
|
240
|
-
|
|
243
|
+
##### Write an SVG to stdout
|
|
241
244
|
|
|
242
245
|
```sh
|
|
243
246
|
tldraw-cli export https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw --print
|
|
244
247
|
```
|
|
245
248
|
|
|
246
|
-
|
|
249
|
+
##### Open a tldraw\.com URL
|
|
247
250
|
|
|
248
251
|
```sh
|
|
249
252
|
tldraw-cli open https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw
|
|
@@ -251,7 +254,7 @@ tldraw-cli open https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw
|
|
|
251
254
|
|
|
252
255
|
The remote sketch is copied to a locally-hosted instance of tldraw, which is then opened in your default browser.
|
|
253
256
|
|
|
254
|
-
|
|
257
|
+
### API
|
|
255
258
|
|
|
256
259
|
The `export` command's functionality is also provided in module form for use in TypeScript or JavaScript Node projects.
|
|
257
260
|
|
|
@@ -356,6 +359,8 @@ In terms of Puppeteer vs. Playwright and other headless browser automation tools
|
|
|
356
359
|
|
|
357
360
|
The local instance of tldraw includes its assets dependencies, so the tool should work correctly without internet access.
|
|
358
361
|
|
|
362
|
+
Track the [tldraw changelog](https://github.com/tldraw/tldraw/blob/main/CHANGELOG.md).
|
|
363
|
+
|
|
359
364
|
## The future
|
|
360
365
|
|
|
361
366
|
Current plans for future improvements include the following:
|
|
@@ -374,6 +379,10 @@ Eventually, I think it would make sense for some kind of CLI tool like this one
|
|
|
374
379
|
|
|
375
380
|
I'm consciously releasing this tool under the `@kitschpatrol` namespace on NPM to leave the `tldraw-cli` package name available to the core tldraw project.
|
|
376
381
|
|
|
382
|
+
## Maintainers
|
|
383
|
+
|
|
384
|
+
[@kitschpatrol](https://github.com/kitschpatrol)
|
|
385
|
+
|
|
377
386
|
<!-- footer -->
|
|
378
387
|
|
|
379
388
|
## Contributing
|