Commit 004d0bb
authored
ENG-889: Render SmartBlocks as interactive buttons in left sidebar (#940)
* ENG-889: Render SmartBlocks as interactive buttons in left sidebar
Block references containing SmartBlock syntax (`:SmartBlock:` buttons
or `<%` workflows) now render via Roam's renderBlock API instead of
plain text. Clicking a SmartBlock button navigates to the block.
- Add RoamRenderedBlock component using renderBlock with open?:false
- Extract hasSmartBlockSyntax to module level in createDiscourseNode,
add isSmartBlockUid export for sidebar/settings detection
- Hide alias settings gear for SmartBlock children
- Inject CSS once in mountLeftSidebar to hide Roam chrome
- Add "DG: Favorites - Add to Global section" context menu with
dual-write (restores global support removed in PR #902 self-review)
* Address review: use react.block and move isSmartBlockUid
- Replace useEffect+renderBlock with roamAlphaAPI.ui.components.react.block
- Simplify isSmartBlockUid to only check :SmartBlock: text
- Move isSmartBlockUid to getLeftSidebarSettings (shared by both consumers)
- Restore hasSmartBlockSyntax as local fn in createDiscourseNode
* Add ts-expect-error for untyped react.block API
* Address review: use RenderRoamBlock util and extract isSmartBlockUid
- Use RenderRoamBlock from ~/utils/roamReactComponents (correct API
path: ui.react.Block, not ui.components.react.block). Fixes runtime
break and removes the @ts-expect-error + eslint-disables.
- Move isSmartBlockUid into its own file at ~/utils/isSmartBlockUid.ts.
* Fix sidebar SmartBlocks: stop click navigation, refresh on text change
- Remove openBlock click handler. SmartBlock buttons handle their own
clicks; the wrapper was running the SmartBlock AND navigating to its
source block.
- Pull-watch :block/string and force RenderRoamBlock remount via key.
Roam's react.Block doesn't re-render on text changes when used outside
the main render tree, so editing a SmartBlock action left the sidebar
showing the previous action.
* Rename SmartBlock button ref helper1 parent 3c66a72 commit 004d0bb
5 files changed
Lines changed: 135 additions & 11 deletions
File tree
- apps/roam/src
- components
- settings
- utils
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
| 52 | + | |
51 | 53 | | |
52 | 54 | | |
53 | 55 | | |
| |||
135 | 137 | | |
136 | 138 | | |
137 | 139 | | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
138 | 160 | | |
139 | 161 | | |
140 | 162 | | |
| |||
147 | 169 | | |
148 | 170 | | |
149 | 171 | | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
150 | 183 | | |
151 | 184 | | |
152 | 185 | | |
| |||
701 | 734 | | |
702 | 735 | | |
703 | 736 | | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
704 | 753 | | |
705 | 754 | | |
706 | 755 | | |
| |||
Lines changed: 19 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
49 | 55 | | |
50 | 56 | | |
51 | 57 | | |
| |||
429 | 435 | | |
430 | 436 | | |
431 | 437 | | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
432 | 441 | | |
433 | 442 | | |
434 | 443 | | |
| |||
444 | 453 | | |
445 | 454 | | |
446 | 455 | | |
447 | | - | |
| 456 | + | |
448 | 457 | | |
449 | 458 | | |
450 | 459 | | |
| |||
458 | 467 | | |
459 | 468 | | |
460 | 469 | | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | | - | |
466 | | - | |
467 | | - | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
468 | 479 | | |
469 | 480 | | |
470 | 481 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
166 | | - | |
| 166 | + | |
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
27 | 30 | | |
28 | 31 | | |
29 | 32 | | |
30 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
31 | 37 | | |
32 | 38 | | |
33 | 39 | | |
| |||
364 | 370 | | |
365 | 371 | | |
366 | 372 | | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
367 | 389 | | |
368 | 390 | | |
369 | 391 | | |
| |||
427 | 449 | | |
428 | 450 | | |
429 | 451 | | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
0 commit comments