-
Notifications
You must be signed in to change notification settings - Fork 4
ENG-889: Render SmartBlocks as interactive buttons in left sidebar #940
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,25 @@ import { OnloadArgs, RoamBasicNode } from "roamjs-components/types"; | |
| import runQuery from "./runQuery"; | ||
| import updateBlock from "roamjs-components/writes/updateBlock"; | ||
| import posthog from "posthog-js"; | ||
| import getBasicTreeByParentUid from "roamjs-components/queries/getBasicTreeByParentUid"; | ||
| import getTextByBlockUid from "roamjs-components/queries/getTextByBlockUid"; | ||
|
|
||
| const hasSmartBlockSyntax = (node: RoamBasicNode): boolean => { | ||
| if (node.text.includes("<%")) return true; | ||
| if (node.children) return node.children.some(hasSmartBlockSyntax); | ||
| return false; | ||
| }; | ||
|
|
||
| export const isSmartBlockUid = (uid: string): boolean => { | ||
| const text = getTextByBlockUid(uid); | ||
| if (!text) return false; | ||
| if (text.includes(":SmartBlock:")) return true; | ||
| return hasSmartBlockSyntax({ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What use case is this solving for?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As discussed in 1:1 |
||
| text, | ||
| uid, | ||
| children: getBasicTreeByParentUid(uid), | ||
| }); | ||
| }; | ||
|
|
||
| type Props = { | ||
| text: string; | ||
|
|
@@ -163,11 +182,6 @@ const createDiscourseNode = async ({ | |
| await handleImageCreation(pageUid); | ||
| }; | ||
|
|
||
| const hasSmartBlockSyntax = (node: RoamBasicNode) => { | ||
| if (node.text.includes("<%")) return true; | ||
| if (node.children) return node.children.some(hasSmartBlockSyntax); | ||
| return false; | ||
| }; | ||
| const useSmartBlocks = hasSmartBlockSyntax(templateNode); | ||
|
|
||
| if (useSmartBlocks && !window.roamjs?.extension?.smartblocks) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use
.react.blockdirectly now without theuseEffecthttps://roamresearch.com/#/app/developer-documentation/page/u8uYakVXB