diff --git a/src/components/Kanban.tsx b/src/components/Kanban.tsx index dd60eb1f..f92dfae0 100644 --- a/src/components/Kanban.tsx +++ b/src/components/Kanban.tsx @@ -19,22 +19,57 @@ import toCellValue from "../utils/toCellValue"; import extractTag from "roamjs-components/util/extractTag"; import deleteBlock from "roamjs-components/writes/deleteBlock"; import getSubTree from "roamjs-components/util/getSubTree"; +import getPageTitleByPageUid from "roamjs-components/queries/getPageTitleByPageUid"; const zPriority = z.record(z.number().min(0).max(1)); type Reprioritize = (args: { uid: string; x: number; y: number }) => void; +const CellEmbed = ({ uid, viewValue }: { uid: string; viewValue: string }) => { + const title = getPageTitleByPageUid(uid); + const contentRef = useRef(null); + const open = + viewValue === "open" ? true : viewValue === "closed" ? false : null; + useEffect(() => { + const el = contentRef.current; + if (el) { + window.roamAlphaAPI.ui.components.renderBlock({ + uid, + el, + // "open?": open, // waiting for roamAlphaAPI to add a open/close to renderBlock + }); + } + }, [contentRef]); + return ( +
+ +
+
+ ); +}; + const KanbanCard = (card: { $priority: number; $reprioritize: Reprioritize; $displayKey: string; + $columnKey: string; + $selectionValues: string[]; $getColumnElement: (x: number) => HTMLDivElement | undefined; result: Result; + view: string; + viewValue: string; }) => { const [isDragging, setIsDragging] = useState(false); return ( { const { x, width } = data.node.getBoundingClientRect(); const el = card.$getColumnElement(x + width / 2); @@ -59,6 +94,7 @@ const KanbanCard = (card: { data-uid={card.result.uid} data-priority={card.$priority} onClick={(e) => { + if (card.view === "embed") return; if (isDragging) return; if (e.shiftKey) { openBlockInSidebar(card.result.uid); @@ -73,12 +109,16 @@ const KanbanCard = (card: { } }} > -
- {toCellValue({ - value: card.result[card.$displayKey], - uid: card.result[`${card.$displayKey}-uid`], - })} -
+ {card.view === "embed" ? ( + + ) : ( +
+ {toCellValue({ + value: card.result[card.$displayKey], + uid: card.result[`${card.$displayKey}-uid`], + })} +
+ )}
); @@ -98,12 +138,14 @@ const Kanban = ({ onQuery, resultKeys, parentUid, + views, }: { resultKeys: Column[]; data: Result[]; layout: Record; onQuery: () => void; parentUid: string; + views: { column: string; mode: string; value: string }[]; }) => { const byUid = useMemo( () => Object.fromEntries(data.map((d) => [d.uid, d] as const)), @@ -347,6 +389,12 @@ const Kanban = ({ setOpenedPopoverIndex(null); }; + const viewsByColumn = useMemo( + () => Object.fromEntries(views.map((v) => [v.column, v])), + [views] + ); + const { mode: view, value: viewValue } = viewsByColumn[displayKey] || {}; + return ( <> {showLegend === "Yes" && ( @@ -438,11 +486,15 @@ const Kanban = ({ rk.key)} /> ))} diff --git a/src/components/ResultsTable.tsx b/src/components/ResultsTable.tsx index e3477ce5..0db261d4 100644 --- a/src/components/ResultsTable.tsx +++ b/src/components/ResultsTable.tsx @@ -164,15 +164,18 @@ const ResultHeader = React.forwardRef< } ); -const CellEmbed = ({ uid }: { uid: string }) => { +const CellEmbed = ({ uid, viewValue }: { uid: string; viewValue: string }) => { const title = getPageTitleByPageUid(uid); const contentRef = useRef(null); + const open = + viewValue === "open" ? true : viewValue === "closed" ? false : null; useEffect(() => { const el = contentRef.current; if (el) { window.roamAlphaAPI.ui.components.renderBlock({ uid, el, + "open?": open, }); } }, [contentRef]); @@ -335,7 +338,7 @@ const ResultRow = ({ {view === "alias" ? viewValue : cell(key)} ) : view === "embed" ? ( - + ) : ( cell(key) )} diff --git a/src/components/ResultsView.tsx b/src/components/ResultsView.tsx index 7d91a359..1311f7e0 100644 --- a/src/components/ResultsView.tsx +++ b/src/components/ResultsView.tsx @@ -10,6 +10,7 @@ import { Switch, Intent, Label, + HTMLTable, } from "@blueprintjs/core"; import getBasicTreeByParentUid from "roamjs-components/queries/getBasicTreeByParentUid"; import { Filters } from "roamjs-components/components/Filter"; @@ -40,9 +41,10 @@ import { render as renderSimpleAlert } from "roamjs-components/components/Simple const VIEWS: Record = { link: { value: false }, plain: { value: false }, - embed: { value: false }, + embed: { value: true }, alias: { value: true }, }; +const EMBED_FOLD_VALUES = ["default", "open", "closed"]; type EnglishQueryPart = { text: string; clickId?: string }; @@ -343,12 +345,14 @@ const ResultsView: ResultsViewComponent = ({ ); }; const debounceRef = useRef(0); + const showColumnViewOptions = views.some( + (view) => VIEWS[view.mode]?.value === true + ); + return (
setShowMenuIcons(true)} - onMouseOut={() => setShowMenuIcons(false)} > {isEditSearchFilter && (
- { + if (!showInterface) setShowMenuIcons(true); + }} + onMouseLeave={() => { + if (!showInterface) setShowMenuIcons(false); + }} > - {onRefresh && ( - -
- ) : isEditLayout ? ( -
-

- Layout -

-
- {SUPPORTED_LAYOUTS.map((l) => ( -
{ - setLayout({ ...layout, mode: l.id }); - const resultNode = getSubTree({ - key: "results", - parentUid, - }); - const layoutNode = getSubTree({ - key: "layout", - parentUid: resultNode.uid, - }); - setInputSetting({ - key: "mode", - value: l.id, - blockUid: layoutNode.uid, - }); - setIsEditLayout(false); - setMoreMenuOpen(false); - }} - > - - {l.id} -
- ))}
- {settingsById[layoutMode].map((s) => { - const options = - s.options === "columns" - ? columns.map((c) => c.key) - : s.options.slice(); - return ( -
+
{header && (

onRefresh(true)} resultKeys={columns} parentUid={parentUid} + views={views} /> ) : (
diff --git a/src/index.ts b/src/index.ts index 306d599a..526cc0a5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -153,7 +153,7 @@ svg.rs-svg-container { } .roamjs-kanban-container div.react-draggable-dragging.roamjs-kanban-card > div { - transform: rotate(20deg); + transform: rotate(5deg); cursor: grabbing; z-index: 1000; } @@ -182,7 +182,14 @@ svg.rs-svg-container { .roamjs-export-dialog-body .bp3-tab-list { padding: 10px 20px; border-bottom: 1px solid rgba(16,22,26,0.15); -}`); +} +.roamjs-query-column-views .bp3-running-text table th, +.roamjs-query-column-views table.bp3-html-table th, +.roamjs-query-column-views .bp3-running-text table td, +.roamjs-query-column-views table.bp3-html-table td { + vertical-align: initial; +} +`); const isCanvasPage = (title: string) => { const canvasPageFormat = (extensionAPI.settings.get("canvas-page-format") as string) ||