Commit e86c905
feat(tldraw): show a loading placeholder for pasted bookmarks (tldraw#8663)
In order to make pasting URLs feel responsive even when bookmark
metadata is slow to fetch, this PR creates the bookmark shape
immediately as a placeholder and hydrates it with metadata in the
background. The placeholder shows a loading spinner overlay (similar to
image loading) so the loading state is visible at the paste location,
and once metadata resolves the asset is patched in. If the fetch fails,
the bookmark gracefully falls back to a URL-only card.
<img width="2272" height="1396" alt="Kapture 2026-06-18 at 12 28 53"
src="https://github.com/user-attachments/assets/f0b9516c-59b9-4cec-a9a8-755c0be0693d"
/>
Closes tldraw#8653
### Change type
- [x] `feature`
### Test plan
1. Run `yarn dev`, open the examples app, and paste a URL onto the
canvas — a bookmark placeholder should appear immediately at the paste
location.
2. Throttle the network in DevTools and paste again — the placeholder
with its loading spinner should be visible while metadata loads, then
resolve into the full bookmark preview.
3. Paste a recognized embed URL (e.g. a YouTube link) — it should still
create an embed shape, not a bookmark placeholder.
4. Paste a URL that fails to unfurl — the bookmark should remain visible
as a URL-only card rather than disappearing.
5. Paste a URL, then immediately undo — the placeholder should disappear
cleanly without leaving an extra "metadata loaded" undo step.
- [x] Unit tests
- [ ] End to end tests
### Release notes
- Pasted bookmarks now show an immediate loading placeholder at the
paste location, with a loading spinner, instead of waiting for metadata
before appearing.
### API changes
- BookmarkShapeUtil now uses `getGeometry` to explicitly define its
geometry.
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 8d86bc3 commit e86c905
4 files changed
Lines changed: 379 additions & 46 deletions
File tree
- packages/tldraw
- src
- lib/shapes/bookmark
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
534 | 534 | | |
535 | 535 | | |
536 | 536 | | |
| 537 | + | |
| 538 | + | |
537 | 539 | | |
538 | 540 | | |
539 | 541 | | |
| |||
Lines changed: 16 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| 28 | + | |
27 | 29 | | |
| 30 | + | |
28 | 31 | | |
29 | 32 | | |
30 | 33 | | |
| |||
87 | 90 | | |
88 | 91 | | |
89 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
90 | 101 | | |
91 | | - | |
| 102 | + | |
| 103 | + | |
92 | 104 | | |
93 | 105 | | |
94 | 106 | | |
95 | 107 | | |
96 | 108 | | |
97 | 109 | | |
98 | 110 | | |
99 | | - | |
| 111 | + | |
100 | 112 | | |
101 | 113 | | |
102 | 114 | | |
| |||
147 | 159 | | |
148 | 160 | | |
149 | 161 | | |
150 | | - | |
| 162 | + | |
| 163 | + | |
151 | 164 | | |
152 | 165 | | |
153 | 166 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
84 | 85 | | |
85 | 86 | | |
86 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
87 | 126 | | |
88 | 127 | | |
89 | 128 | | |
| |||
128 | 167 | | |
129 | 168 | | |
130 | 169 | | |
131 | | - | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
132 | 177 | | |
133 | 178 | | |
134 | 179 | | |
135 | 180 | | |
136 | | - | |
137 | 181 | | |
138 | 182 | | |
139 | 183 | | |
| |||
145 | 189 | | |
146 | 190 | | |
147 | 191 | | |
148 | | - | |
149 | | - | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
150 | 197 | | |
151 | | - | |
152 | 198 | | |
153 | 199 | | |
154 | 200 | | |
| |||
159 | 205 | | |
160 | 206 | | |
161 | 207 | | |
162 | | - | |
| 208 | + | |
163 | 209 | | |
164 | | - | |
| 210 | + | |
165 | 211 | | |
166 | 212 | | |
167 | 213 | | |
168 | 214 | | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | 215 | | |
176 | 216 | | |
177 | 217 | | |
178 | | - | |
179 | | - | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
180 | 233 | | |
181 | 234 | | |
182 | 235 | | |
183 | 236 | | |
184 | 237 | | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
0 commit comments