Commit 7308566
authored
editor: be able to use TldrawEditor without needing
if you wanted to use TldrawEditor by itself, you weren't able to use
some tldraw shapes b/c they relied on `TldrawUiContextProvider` being
present which could bloat your bundle size unnecessarily if you didn't
need all that extra stuff
H/T to @derekcicerone for flagging this one — thanks!
### Change type
- [x] `bugfix`
- [ ] `improvement`
- [ ] `feature`
- [ ] `api`
- [ ] `other`
### Test plan
- [x] Unit tests
- [ ] End to end tests
### Release notes
- editor: be able to use TldrawEditor without needing
`TldrawUiContextProvider`
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Make note shape RTL logic resilient to missing UI translation context
so TldrawEditor works standalone, add CSS.supports polyfill, and expand
shape rendering tests.
>
> - **Editor / Shapes**:
> - Update `NoteShapeUtil` to use optional `TranslationsContext`
(fallback to LTR) for RTL/tab navigation, avoiding hard dependency on
`TldrawUiContextProvider`.
> - **UI / Translations**:
> - Export `TranslationsContext` from
`ui/hooks/useTranslation/useTranslation` (marked internal).
> - **Tests**:
> - Revamp `TldrawEditor.test.tsx` to render and validate all core
shapes (no error boundaries), use `defaultShapeUtils`, and test
selection/tool switching with rich text helpers.
> - **Tooling / Polyfills**:
> - Add `CSS.supports` polyfill in `internal/config/vitest/setup.ts` for
color space-related tests.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
da964bd. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->TldrawUiContextProvider (tldraw#7053)1 parent 8e28283 commit 7308566
4 files changed
Lines changed: 90 additions & 35 deletions
File tree
- internal/config/vitest
- packages/tldraw/src
- lib
- shapes/note
- ui/hooks/useTranslation
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
53 | 61 | | |
54 | 62 | | |
55 | 63 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
493 | 493 | | |
494 | 494 | | |
495 | 495 | | |
496 | | - | |
| 496 | + | |
| 497 | + | |
497 | 498 | | |
498 | 499 | | |
499 | 500 | | |
| |||
512 | 513 | | |
513 | 514 | | |
514 | 515 | | |
515 | | - | |
| 516 | + | |
516 | 517 | | |
517 | 518 | | |
518 | 519 | | |
| |||
540 | 541 | | |
541 | 542 | | |
542 | 543 | | |
543 | | - | |
| 544 | + | |
544 | 545 | | |
545 | 546 | | |
546 | 547 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
18 | | - | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
169 | 170 | | |
170 | 171 | | |
171 | 172 | | |
172 | | - | |
| 173 | + | |
173 | 174 | | |
174 | 175 | | |
175 | 176 | | |
| |||
185 | 186 | | |
186 | 187 | | |
187 | 188 | | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
196 | 212 | | |
197 | | - | |
198 | | - | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
199 | 249 | | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
209 | 254 | | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
214 | 259 | | |
215 | | - | |
216 | | - | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
217 | 263 | | |
218 | 264 | | |
219 | | - | |
220 | | - | |
| 265 | + | |
221 | 266 | | |
222 | 267 | | |
223 | 268 | | |
| |||
0 commit comments